|
| 1 | +name: gh-package-deploy |
| 2 | +permissions: {} |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - master |
| 8 | + tags: |
| 9 | + - '*' |
| 10 | + |
| 11 | +env: |
| 12 | + REGISTRY: ghcr.io |
| 13 | + IMAGE_NAME: "${{ github.repository }}" |
| 14 | + |
| 15 | +jobs: |
| 16 | + docker: |
| 17 | + if: ${{ github.actor != 'dependabot[bot]' }} |
| 18 | + |
| 19 | + runs-on: ubuntu-latest |
| 20 | + # Adding this block will overridw default values to None if not specified in the block |
| 21 | + # https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs |
| 22 | + permissions: |
| 23 | + contents: read |
| 24 | + actions: read |
| 25 | + packages: write # to push packages |
| 26 | + steps: |
| 27 | + - name: Checkout |
| 28 | + uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98 |
| 29 | + |
| 30 | + - uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c |
| 31 | + with: |
| 32 | + # https://www.npmjs.com/package/semver#caret-ranges-123-025-004 |
| 33 | + go-version: '^1.26' |
| 34 | + |
| 35 | + - name: Login to Github Container Registry |
| 36 | + uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 |
| 37 | + with: |
| 38 | + registry: ${{ env.REGISTRY }} |
| 39 | + username: ${{ github.actor }} |
| 40 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 41 | + |
| 42 | + - uses: actions-ecosystem/action-get-latest-tag@b7c32daec3395a9616f88548363a42652b22d435 |
| 43 | + id: get-latest-tag |
| 44 | + |
| 45 | + - name: Build binaries |
| 46 | + run: | |
| 47 | + make build.linux.amd64 build.linux.arm64 |
| 48 | +
|
| 49 | + - name: Set up QEMU |
| 50 | + uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a |
| 51 | + |
| 52 | + - name: Set up Docker Buildx |
| 53 | + uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd |
| 54 | + |
| 55 | + - name: Login to GitHub Container Registry |
| 56 | + if: github.event_name != 'pull_request' |
| 57 | + uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 |
| 58 | + with: |
| 59 | + registry: ghcr.io |
| 60 | + username: ${{ github.actor }} |
| 61 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 62 | + |
| 63 | + - name: Docker meta |
| 64 | + uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf |
| 65 | + id: meta |
| 66 | + with: |
| 67 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 68 | + tags: | |
| 69 | + type=semver,pattern=v{{version}} |
| 70 | + type=semver,pattern=v{{major}}.{{minor}} |
| 71 | +
|
| 72 | + - name: Build and push |
| 73 | + uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 |
| 74 | + with: |
| 75 | + context: . |
| 76 | + platforms: linux/amd64,linux/arm64 |
| 77 | + push: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/v') }} |
| 78 | + tags: ${{ steps.meta.outputs.tags }} |
| 79 | + labels: ${{ steps.meta.outputs.labels }} |
| 80 | + |
| 81 | + # Build and push latest tag |
| 82 | + - name: Build and push latest |
| 83 | + uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 |
| 84 | + with: |
| 85 | + context: . |
| 86 | + platforms: linux/amd64,linux/arm64 |
| 87 | + push: ${{ github.event_name != 'pull_request' }} |
| 88 | + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest |
| 89 | + labels: ${{ steps.meta.outputs.labels }} |
0 commit comments