|
| 1 | +name: Docker |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*" |
| 7 | + branches: |
| 8 | + - main |
| 9 | + pull_request: |
| 10 | + |
| 11 | +env: |
| 12 | + GORELEASER_VER: "v2.3.2" |
| 13 | + |
| 14 | +jobs: |
| 15 | + release: |
| 16 | + env: |
| 17 | + flags: "" |
| 18 | + runs-on: ubuntu-latest |
| 19 | + permissions: |
| 20 | + contents: read |
| 21 | + packages: write |
| 22 | + # This is used to complete the identity challenge |
| 23 | + # with sigstore/fulcio when running outside of PRs. |
| 24 | + id-token: write |
| 25 | + |
| 26 | + steps: |
| 27 | + - name: Parse semver string |
| 28 | + id: semver_parser |
| 29 | + uses: booxmedialtd/ws-action-parse-semver@v1 |
| 30 | + with: |
| 31 | + input_string: ${{ (startsWith(github.ref, 'refs/tags/v') && github.ref) || 'refs/tags/v0.0.0' }} |
| 32 | + version_extractor_regex: '\/v(.*)$' |
| 33 | + |
| 34 | + - if: ${{ !startsWith(github.ref, 'refs/tags/v') }} |
| 35 | + run: echo "flags=--snapshot" >> $GITHUB_ENV |
| 36 | + |
| 37 | + - name: Checkout repository |
| 38 | + uses: actions/checkout@v4 |
| 39 | + with: |
| 40 | + fetch-depth: 0 # It is required for GoReleaser to work properly |
| 41 | + |
| 42 | + # Set up BuildKit Docker container builder to be able to build |
| 43 | + # multi-platform images and export cache |
| 44 | + # https://github.com/docker/setup-buildx-action |
| 45 | + - name: Set up Docker Buildx |
| 46 | + uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0 |
| 47 | + |
| 48 | + # Login against a Docker registry except on PR |
| 49 | + # https://github.com/docker/login-action |
| 50 | + - name: Login to Docker hub |
| 51 | + if: github.repository == github.head.repo.full_name || !github.head_ref |
| 52 | + uses: docker/login-action@v1 |
| 53 | + with: |
| 54 | + username: ${{ secrets.DOCKER_USER }} |
| 55 | + password: ${{ secrets.DOCKER_TOKEN }} |
| 56 | + |
| 57 | + - name: Install OS build dependencies |
| 58 | + run: sudo apt update && sudo apt install -y -q gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu |
| 59 | + |
| 60 | + - name: Install goversioninfo |
| 61 | + run: go install github.com/josephspurrier/goversioninfo/cmd/goversioninfo@233067e |
| 62 | + |
| 63 | + - name: Run GoReleaser |
| 64 | + uses: goreleaser/goreleaser-action@v4 |
| 65 | + with: |
| 66 | + version: ${{ env.GORELEASER_VER }} |
| 67 | + args: release --clean ${{ env.flags }} |
| 68 | + env: |
| 69 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments