Skip to content

Commit 281b7c0

Browse files
committed
Merge branch 'development'
2 parents 6a65f3c + b4499f6 commit 281b7c0

6 files changed

+102
-24
lines changed

.github/workflows/deploy_development.yml

+13-5
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,19 @@ on:
1111
- Dockerfile
1212

1313
jobs:
14+
get_latest_version:
15+
uses: ./.github/workflows/get_nexus_version_latest.yml
16+
1417
build_deploy_to_registry:
1518
runs-on: ubuntu-latest
19+
needs: get_latest_version
1620
steps:
1721
- name: Checkout
18-
uses: actions/checkout@v2
22+
uses: actions/checkout@v4
1923

2024
# Enable docker cache to speed-up builds
2125
- name: Setup Docker build cache
22-
uses: actions/cache@v2
26+
uses: actions/cache@v3
2327
with:
2428
path: /tmp/buildx-cache
2529
key: ${{runner.os}}-buildx-${{github.sha}}
@@ -28,27 +32,31 @@ jobs:
2832
2933
# Enable multi-architecture support on build node
3034
- name: Set up QEMU
31-
uses: docker/setup-qemu-action@v1
35+
uses: docker/setup-qemu-action@v3
3236
with:
3337
platforms: all
3438

3539
- name: Set up Docker Buildx
36-
uses: docker/setup-buildx-action@v1
40+
uses: docker/setup-buildx-action@v3
3741
with:
3842
version: latest
3943

4044
- name: Docker login
41-
uses: docker/login-action@v1
45+
uses: docker/login-action@v3
4246
with:
4347
username: ${{secrets.REGISTRY_USERNAME}}
4448
password: ${{secrets.REGISTRY_PASSWORD}}
4549

4650
- name: Build + Push image ("development")
51+
env:
52+
NEXUS_VERSION: ${{needs.get_latest_version.outputs.nexus_version}}
4753
run: |
4854
docker buildx build \
55+
--build-arg "NEXUS_VERSION=${NEXUS_VERSION}" \
4956
--cache-from type=local,src=/tmp/buildx-cache \
5057
--cache-to type=local,dest=/tmp/buildx-cache \
5158
--label org.opencontainers.image.revision="${{github.sha}}" \
59+
--label org.opencontainers.image.version="${NEXUS_VERSION}" \
5260
--platform "linux/arm/v7,linux/arm64" \
5361
--pull \
5462
--tag "${{secrets.REGISTRY_USERNAME}}/nexus3:development" \

.github/workflows/deploy_release.yml

+42-11
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
name: Deploy Release Build
22

3-
# Trigger on release
3+
# Trigger on new version tag
44
on:
5-
release:
6-
types:
7-
- released
5+
push:
6+
tags:
7+
- '[0-9]+.[0-9]+.[0-9]+*'
88

99
jobs:
10+
# get_latest_version:
11+
# uses: ./.github/workflows/get_nexus_version_latest.yml
12+
1013
build_deploy_to_registry:
1114
runs-on: ubuntu-latest
15+
# needs: get_latest_version
1216
steps:
1317
- name: Checkout
14-
uses: actions/checkout@v2
18+
uses: actions/checkout@v4
1519

1620
# Enable docker cache to speed-up builds
1721
- name: Setup Docker build cache
18-
uses: actions/cache@v2
22+
uses: actions/cache@v3
1923
with:
2024
path: /tmp/buildx-cache
2125
key: ${{runner.os}}-buildx-${{github.sha}}
@@ -24,40 +28,67 @@ jobs:
2428
2529
# Enable multi-architecture support on build node
2630
- name: Set up QEMU
27-
uses: docker/setup-qemu-action@v1
31+
uses: docker/setup-qemu-action@v3
2832
with:
2933
platforms: all
3034

3135
- name: Set up Docker Buildx
32-
uses: docker/setup-buildx-action@v1
36+
uses: docker/setup-buildx-action@v3
3337
with:
3438
version: latest
3539

3640
- name: Docker login
37-
uses: docker/login-action@v1
41+
uses: docker/login-action@v3
3842
with:
3943
username: ${{secrets.REGISTRY_USERNAME}}
4044
password: ${{secrets.REGISTRY_PASSWORD}}
4145

42-
- name: Build + Push image (tag = git release tag)
46+
- name: Build + Push image (tag = git tag)
47+
env:
48+
# `github.ref_name` == git tag triggered build
49+
NEXUS_VERSION: ${{github.ref_name}}
4350
run: |
4451
docker buildx build \
52+
--build-arg "NEXUS_VERSION=${NEXUS_VERSION}" \
4553
--cache-from type=local,src=/tmp/buildx-cache \
4654
--cache-to type=local,dest=/tmp/buildx-cache \
4755
--label org.opencontainers.image.revision="${{github.sha}}" \
56+
--label org.opencontainers.image.version="${NEXUS_VERSION}" \
4857
--platform "linux/arm/v7,linux/arm64" \
4958
--pull \
50-
--tag "${{secrets.REGISTRY_USERNAME}}/nexus3:${GITHUB_REF#refs/tags/}" \
59+
--tag "${{secrets.REGISTRY_USERNAME}}/nexus3:${NEXUS_VERSION}" \
5160
--output "type=image,push=true" \
5261
--file ./Dockerfile .
5362
5463
- name: Build + Push image ("latest")
64+
env:
65+
# `github.ref_name` == git tag triggered build
66+
NEXUS_VERSION: ${{github.ref_name}}
5567
run: |
5668
docker buildx build \
69+
--build-arg "NEXUS_VERSION=${NEXUS_VERSION}" \
5770
--cache-from type=local,src=/tmp/buildx-cache \
5871
--cache-to type=local,dest=/tmp/buildx-cache \
5972
--label org.opencontainers.image.revision="${{github.sha}}" \
73+
--label org.opencontainers.image.version="${NEXUS_VERSION}" \
6074
--platform "linux/arm/v7,linux/arm64" \
6175
--tag "${{secrets.REGISTRY_USERNAME}}/nexus3:latest" \
6276
--output "type=image,push=true" \
6377
--file ./Dockerfile .
78+
79+
create_release:
80+
runs-on: ubuntu-latest
81+
permissions:
82+
contents: write
83+
needs: build_deploy_to_registry
84+
steps:
85+
- name: Create Github Release
86+
uses: ncipollo/[email protected]
87+
with:
88+
tag: ${{github.ref_name}}
89+
name: ${{github.ref_name}}
90+
body: (Automated release)
91+
draft: false
92+
prerelease: false
93+
# Allow re-run workflow job
94+
skipIfReleaseExists: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Get Latest Nexus Version
2+
3+
on:
4+
workflow_call:
5+
outputs:
6+
nexus_version:
7+
description: Latest Nexus Version
8+
value: ${{ jobs.get_latest_version.outputs.nexus_version }}
9+
10+
jobs:
11+
get_latest_version:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
NEXUS_VERSION: ${{ steps.getversion.outputs.nexus_version }}
15+
steps:
16+
- id: getversion
17+
name: Get Nexus Version
18+
run: |
19+
set -eu -o pipefail
20+
NEXUS_VERSION="$(curl --silent 'https://raw.githubusercontent.com/sonatype/docker-nexus3/main/Dockerfile'|grep -Ei '^ARG NEXUS_VERSION'|cut --delimiter='=' --fields=2|tr --delete '[:space:]')"
21+
echo "DEBUG: ${NEXUS_VERSION}"
22+
echo "nexus_version=${NEXUS_VERSION}" >> "$GITHUB_OUTPUT"

.github/workflows/github_cache_warmer.yml

+12-4
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,19 @@ on:
1111
workflow_dispatch:
1212

1313
jobs:
14+
get_latest_version:
15+
uses: ./.github/workflows/get_nexus_version_latest.yml
16+
1417
build_image_to_cache:
1518
runs-on: ubuntu-latest
19+
needs: get_latest_version
1620
steps:
1721
- name: Checkout
18-
uses: actions/checkout@v2
22+
uses: actions/checkout@v4
1923

2024
# Setup docker cache to keep warm
2125
- name: Setup Docker build cache
22-
uses: actions/cache@v2
26+
uses: actions/cache@v3
2327
with:
2428
path: /tmp/buildx-cache
2529
key: ${{runner.os}}-buildx-${{github.sha}}
@@ -28,21 +32,25 @@ jobs:
2832
2933
# Enable multi-architecture support on build node
3034
- name: Set up QEMU
31-
uses: docker/setup-qemu-action@v1
35+
uses: docker/setup-qemu-action@v3
3236
with:
3337
platforms: all
3438

3539
- name: Set up Docker Buildx
36-
uses: docker/setup-buildx-action@v1
40+
uses: docker/setup-buildx-action@v3
3741
with:
3842
version: latest
3943

4044
- name: Build to GitHub cache (keep it warm)
45+
env:
46+
NEXUS_VERSION: ${{needs.get_latest_version.outputs.nexus_version}}
4147
run: |
4248
docker buildx build \
49+
--build-arg "NEXUS_VERSION=${NEXUS_VERSION}" \
4350
--cache-from type=local,src=/tmp/buildx-cache \
4451
--cache-to type=local,dest=/tmp/buildx-cache \
4552
--label org.opencontainers.image.revision="${{github.sha}}" \
53+
--label org.opencontainers.image.version="${NEXUS_VERSION}" \
4654
--platform "linux/arm/v7,linux/arm64" \
4755
--pull \
4856
--output "type=image,push=false" \

.github/workflows/validate_pull_request.yml

+11-3
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,36 @@ on:
1111
- Dockerfile
1212

1313
jobs:
14+
get_latest_version:
15+
uses: ./.github/workflows/get_nexus_version_latest.yml
16+
1417
# Verify image build success
1518
build_image:
1619
runs-on: ubuntu-latest
20+
needs: get_latest_version
1721
steps:
1822
- name: Checkout
19-
uses: actions/checkout@v2
23+
uses: actions/checkout@v4
2024

2125
# Enable multi-architecture support on build node
2226
- name: Set up QEMU
23-
uses: docker/setup-qemu-action@v1
27+
uses: docker/setup-qemu-action@v3
2428
with:
2529
platforms: all
2630

2731
- name: Set up Docker Buildx
28-
uses: docker/setup-buildx-action@v1
32+
uses: docker/setup-buildx-action@v3
2933
with:
3034
version: latest
3135

3236
- name: Build image (no push)
37+
env:
38+
NEXUS_VERSION: ${{needs.get_latest_version.outputs.nexus_version}}
3339
run: |
3440
docker buildx build \
41+
--build-arg "NEXUS_VERSION=${NEXUS_VERSION}" \
3542
--label org.opencontainers.image.revision="${{github.sha}}" \
43+
--label org.opencontainers.image.version="${NEXUS_VERSION}" \
3644
--platform "linux/arm/v7,linux/arm64" \
3745
--pull \
3846
--output "type=image,push=false" \

Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Download, extract Nexus to /tmp/sonatype/nexus
22
FROM eclipse-temurin:8-jre-jammy as downloader
33

4-
ARG NEXUS_VERSION=3.43.0-01
4+
ARG NEXUS_VERSION=${NEXUS_VERSION}
55
ARG NEXUS_DOWNLOAD_URL=https://download.sonatype.com/nexus/3/nexus-${NEXUS_VERSION}-unix.tar.gz
66

77
# Download Nexus and other stuff we need later
@@ -27,6 +27,7 @@ FROM eclipse-temurin:8-jre-jammy
2727
# git commit
2828
LABEL org.opencontainers.image.revision="-"
2929
LABEL org.opencontainers.image.source="https://github.com/klo2k/nexus3-docker"
30+
LABEL org.opencontainers.image.version="-"
3031

3132
# Setup: Rename App, Data and Work directory per official image
3233
# App directory (/opt/sonatype/nexus)

0 commit comments

Comments
 (0)