|
6 | 6 | - master
|
7 | 7 | pull_request:
|
8 | 8 |
|
| 9 | +env: |
| 10 | + REGISTRY: ghcr.io |
| 11 | + IMAGE_NAME: ${{ github.repository }} |
| 12 | + |
9 | 13 | jobs:
|
10 |
| - build-and-release: |
| 14 | + build_and_release: |
11 | 15 | runs-on: ubuntu-latest
|
| 16 | + |
| 17 | + outputs: |
| 18 | + new_release_major_version: ${{ steps.semantic.outputs.new_release_major_version }} |
| 19 | + new_release_minor_version: ${{ steps.semantic.outputs.new_release_minor_version }} |
| 20 | + new_release_patch_version: ${{ steps.semantic.outputs.new_release_patch_version }} |
| 21 | + new_release_version: ${{ steps.semantic.outputs.new_release_version }} |
| 22 | + |
12 | 23 | steps:
|
13 | 24 | - uses: actions/checkout@v2
|
14 | 25 | - uses: actions/setup-go@v2
|
15 | 26 | with:
|
16 | 27 | go-version: 1.16
|
17 | 28 | - run: go build -v ./...
|
18 | 29 | - run: go test -v ./...
|
19 |
| - - uses: go-semantic-release/action@v1 |
20 |
| - if: ${{ github.ref == 'refs/heads/master' }} |
| 30 | + |
| 31 | + - name: Semantic Release |
| 32 | + if: ${{ github.ref == '/refs/heads/master' }} |
| 33 | + id: semantic |
| 34 | + uses: cycjimmy/semantic-release-action@v2 |
| 35 | + with: |
| 36 | + semantic_version: 16 |
| 37 | + env: |
| 38 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 39 | + |
| 40 | + docker_release: |
| 41 | + runs-on: ubuntu-latest |
| 42 | + |
| 43 | + if: ${{ github.ref == '/refs/heads/master' }} |
| 44 | + |
| 45 | + needs: |
| 46 | + - build_and_release |
| 47 | + |
| 48 | + permissions: |
| 49 | + contents: read |
| 50 | + packages: write |
| 51 | + |
| 52 | + steps: |
| 53 | + - name: Checkout repository |
| 54 | + uses: actions/checkout@v2 |
| 55 | + |
| 56 | + - name: Log into registry ${{ env.REGISTRY }} |
| 57 | + uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c |
| 58 | + with: |
| 59 | + registry: ${{ env.REGISTRY }} |
| 60 | + username: ${{ github.actor }} |
| 61 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 62 | + |
| 63 | + - uses: docker/setup-qemu-action@master |
| 64 | + with: |
| 65 | + platforms: all |
| 66 | + |
| 67 | + - name: Extract Docker metadata |
| 68 | + id: meta |
| 69 | + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 |
| 70 | + with: |
| 71 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 72 | + tags: | |
| 73 | + type=raw,enable=true,prefix=v,value=${{ needs.build_and_release.new_release_version }} |
| 74 | + type=raw,enable=true,prefix=v,value=${{ needs.build_and_release.new_release_major_version }} |
| 75 | + type=raw,enable=true,prefix=v,value=${{ needs.build_and_release.new_release_major_version }}.${{ steps.semantic.outputs.new_release_major_version }} |
| 76 | +
|
| 77 | + - name: Set up Docker Buildx |
| 78 | + id: buildx |
| 79 | + uses: docker/setup-buildx-action@master |
| 80 | + |
| 81 | + - name: Build and push Docker image |
| 82 | + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc |
21 | 83 | with:
|
22 |
| - github-token: ${{ secrets.GITHUB_TOKEN }} |
23 |
| - allow-initial-development-versions: true |
| 84 | + builder: ${{ steps.buildx.outputs.name }} |
| 85 | + context: . |
| 86 | + tags: ${{ steps.meta.outputs.tags }} |
| 87 | + labels: ${{ steps.meta.outputs.labels }} |
| 88 | + platforms: linux/amd64,linux/arm64 |
0 commit comments