|
| 1 | +name: Container |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + pull_request: |
| 7 | + branches: [ main ] |
| 8 | + |
| 9 | +env: |
| 10 | + # renovate: datasource=go depName=github.com/goreleaser/goreleaser |
| 11 | + GORELEASER_VERSION: v1.10.2 |
| 12 | + |
| 13 | +jobs: |
| 14 | + skip-check: |
| 15 | + name: Skip check |
| 16 | + continue-on-error: true |
| 17 | + runs-on: ubuntu-latest |
| 18 | + outputs: |
| 19 | + should_skip: ${{ steps.skip-check.outputs.should_skip }} |
| 20 | + permissions: |
| 21 | + actions: write |
| 22 | + contents: read |
| 23 | + steps: |
| 24 | + - id: skip-check |
| 25 | + uses: fkirc/skip-duplicate-actions@9d116fa7e55f295019cfab7e3ab72b478bcf7fdd # tag=v4.0.0 |
| 26 | + with: |
| 27 | + do_not_skip: '["schedule", "workflow_dispatch"]' |
| 28 | + paths: |- |
| 29 | + [ |
| 30 | + "**.go", |
| 31 | + ".dockerignore", |
| 32 | + ".github/workflows/container.yml", |
| 33 | + "Dockerfile*", |
| 34 | + "Makefile", |
| 35 | + "go.mod", |
| 36 | + "go.sum" |
| 37 | + ] |
| 38 | + skip_after_successful_duplicate: false |
| 39 | + |
| 40 | + |
| 41 | + build-binaries: |
| 42 | + name: Build binaries using goreleaser |
| 43 | + needs: skip-check |
| 44 | + if: ${{ needs.skip-check.outputs.should_skip != 'true' }} |
| 45 | + runs-on: ubuntu-latest |
| 46 | + container: |
| 47 | + image: docker.io/goreleaser/goreleaser-cross:v1.18.3 |
| 48 | + options: --privileged |
| 49 | + env: |
| 50 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 51 | + GORELEASER_CURRENT_TAG: "${{ env.goreleaser_current_tag }}" |
| 52 | + steps: |
| 53 | + - name: Check out the code |
| 54 | + uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2 |
| 55 | + |
| 56 | + - name: Set up Go |
| 57 | + uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a # tag=v3.2.1 |
| 58 | + with: |
| 59 | + go-version-file: 'go.mod' |
| 60 | + cache: true |
| 61 | + |
| 62 | + - name: Run Goreleaser |
| 63 | + run: goreleaser release --rm-dist --skip-validate --skip-publish --snapshot --debug |
| 64 | + |
| 65 | + - name: Archive generated artifacts |
| 66 | + uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # tag=v3.1.0 |
| 67 | + with: |
| 68 | + name: parca-push-dist-container |
| 69 | + if-no-files-found: error |
| 70 | + path: | |
| 71 | + goreleaser/dist |
| 72 | + !goreleaser/dist/*.txt |
| 73 | +
|
| 74 | + build-and-push-container: |
| 75 | + name: Container build and push (when merged) |
| 76 | + needs: build-binaries |
| 77 | + runs-on: ubuntu-latest |
| 78 | + container: |
| 79 | + # https://github.com/containers/podman/tree/main/contrib/podmanimage |
| 80 | + # Specifying SHA repeatedly fails: |
| 81 | + # @sha256:421ac576cebff98e90c531e7b9ce4482370ecc7cee59abc2341714031bfb5f43 |
| 82 | + image: quay.io/containers/podman:v4.1.1 |
| 83 | + options: >- |
| 84 | + --device /dev/fuse:rw |
| 85 | + --privileged |
| 86 | + --security-opt label=disable |
| 87 | + --security-opt seccomp=unconfined |
| 88 | + permissions: |
| 89 | + id-token: write |
| 90 | + packages: write |
| 91 | + contents: read |
| 92 | + steps: |
| 93 | + - name: Install dependencies |
| 94 | + run: dnf install --assumeyes --repo fedora git make jq |
| 95 | + |
| 96 | + - name: Check out code into the Go module directory |
| 97 | + uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2 |
| 98 | + |
| 99 | + - name: Set up Go |
| 100 | + uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a # tag=v3.2.1 |
| 101 | + with: |
| 102 | + go-version-file: 'go.mod' |
| 103 | + check-latest: true |
| 104 | + |
| 105 | + - uses: actions/download-artifact@v3 |
| 106 | + with: |
| 107 | + name: parca-push-dist-container |
| 108 | + path: goreleaser/dist |
| 109 | + |
| 110 | + - name: Build container |
| 111 | + run: make container |
| 112 | + |
| 113 | + - name: Check images are created |
| 114 | + run: podman images | grep 'ghcr.io/parca-dev/parca-push' |
| 115 | + |
| 116 | + - name: Install cosign |
| 117 | + if: ${{ github.event_name != 'pull_request' }} |
| 118 | + uses: sigstore/cosign-installer@09a077b27eb1310dcfb21981bee195b30ce09de0 # tag=v2.5.0 |
| 119 | + |
| 120 | + - name: Login to registry |
| 121 | + if: ${{ github.event_name != 'pull_request' }} |
| 122 | + run: | |
| 123 | + echo "${{ secrets.GITHUB_TOKEN }}" | podman login -u parca-dev --password-stdin ghcr.io |
| 124 | +
|
| 125 | + - name: Install crane |
| 126 | + if: ${{ github.event_name != 'pull_request' }} |
| 127 | + uses: imjasonh/setup-crane@e82f1b9a8007d399333baba4d75915558e9fb6a4 # tag=v0.2 |
| 128 | + |
| 129 | + - name: Push and sign container |
| 130 | + if: ${{ github.event_name != 'pull_request' }} |
| 131 | + env: |
| 132 | + COSIGN_EXPERIMENTAL: true |
| 133 | + run: | |
| 134 | + make push-container |
| 135 | + make sign-container |
0 commit comments