|
| 1 | +name: "Release" |
| 2 | + |
| 3 | +# Only trigger if we changed the files used in the image |
| 4 | +on: |
| 5 | + workflow_dispatch: |
| 6 | + push: |
| 7 | + tags: ['v*'] |
| 8 | + |
| 9 | +jobs: |
| 10 | + |
| 11 | + basic_smoketest: |
| 12 | + name: "Basic Smoke Test" |
| 13 | + uses: ./.github/workflows/main.yml |
| 14 | + secrets: inherit |
| 15 | + |
| 16 | + docker-release: |
| 17 | + name: "Release Docker Image" |
| 18 | + runs-on: ubuntu-latest |
| 19 | + needs: ['basic_smoketest'] |
| 20 | + permissions: |
| 21 | + contents: read |
| 22 | + packages: write |
| 23 | + strategy: |
| 24 | + matrix: |
| 25 | + target: |
| 26 | + - Dockerfile: docker/Dockerfile |
| 27 | + - Dockerfile: docker/Dockerfile.alpine |
| 28 | + steps: |
| 29 | + |
| 30 | + - name: Checkout |
| 31 | + uses: actions/checkout@v3 |
| 32 | + |
| 33 | + - name: Prepare Tags |
| 34 | + id: prepare |
| 35 | + run: | |
| 36 | + TAG=${GITHUB_REF#refs/tags/} |
| 37 | + MAJOR_MINOR=${TAG%.*} |
| 38 | + MAJOR_ONLY=${TAG%.*.*} |
| 39 | + SHORT_COMMIT=${GITHUB_SHA::8} |
| 40 | + DATE=$(date '+%Y-%m-%dT%H:%M:%SZ') |
| 41 | + echo ::set-output name=tag_name::${TAG} |
| 42 | + echo ::set-output name=major_tag::${MAJOR_ONLY} |
| 43 | + echo ::set-output name=major_minor_tag::${MAJOR_MINOR} |
| 44 | + echo ::set-output name=short_commit::${SHORT_COMMIT} |
| 45 | + echo ::set-output name=date::${DATE} |
| 46 | + if [[ ${{ matrix.target.Dockerfile }} == *"alpine"* ]]; then |
| 47 | + echo ::set-output name=full_tag_name::${TAG}-alpine |
| 48 | + echo ::set-output name=full_major_tag::${MAJOR_ONLY}-alpine |
| 49 | + echo ::set-output name=full_major_minor_tag::${MAJOR_MINOR}-alpine |
| 50 | + echo ::set-output name=latest_tag::latest-alpine |
| 51 | + else |
| 52 | + echo ::set-output name=full_tag_name::${TAG} |
| 53 | + echo ::set-output name=full_major_tag::${MAJOR_ONLY} |
| 54 | + echo ::set-output name=full_major_minor_tag::${MAJOR_MINOR} |
| 55 | + echo ::set-output name=latest_tag::latest |
| 56 | + fi |
| 57 | +
|
| 58 | + |
| 59 | + - name: Log in to the Container registry |
| 60 | + uses: docker/login-action@v2 |
| 61 | + with: |
| 62 | + registry: ghcr.io |
| 63 | + username: ${{ github.actor }} |
| 64 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 65 | + |
| 66 | + - name: Set up QEMU |
| 67 | + uses: docker/setup-qemu-action@v2 |
| 68 | + |
| 69 | + - name: Setup up Docker Buildx |
| 70 | + uses: docker/setup-buildx-action@v2 |
| 71 | + |
| 72 | + - name: Build and publish ${{ matrix.target.Dockerfile }} |
| 73 | + uses: docker/build-push-action@v3 |
| 74 | + with: |
| 75 | + context: . |
| 76 | + file: ${{ matrix.target.Dockerfile }} |
| 77 | + platforms: linux/amd64,linux/arm64 |
| 78 | + push: true |
| 79 | + build-args: | |
| 80 | + BUILD_VERSION=${{ steps.prepare.outputs.tag_name }} |
| 81 | + BUILD_SHA=${{ steps.prepare.outputs.short_commit }} |
| 82 | + tags: | |
| 83 | + ghcr.io/${{ github.repository }}:${{ steps.prepare.outputs.full_tag_name }} |
| 84 | + ghcr.io/${{ github.repository }}:${{ steps.prepare.outputs.full_major_tag }} |
| 85 | + ghcr.io/${{ github.repository }}:${{ steps.prepare.outputs.full_major_minor_tag }} |
| 86 | + ghcr.io/${{ github.repository }}:${{ steps.prepare.outputs.latest_tag }} |
| 87 | + cache-from: type=gha |
| 88 | + cache-to: type=gha,mode=max |
| 89 | + |
| 90 | + release-github: |
| 91 | + name: 'Create GitHub release' |
| 92 | + # if: "startsWith(github.ref, 'refs/tags/v')" |
| 93 | + needs: ['docker-release'] |
| 94 | + runs-on: 'ubuntu-latest' |
| 95 | + permissions: |
| 96 | + contents: 'write' |
| 97 | + steps: |
| 98 | + - name: Release |
| 99 | + uses: softprops/action-gh-release@v1 |
| 100 | + |
0 commit comments