Fix wpmjson config side effects #368
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: ci | |
| on: | |
| push: | |
| branches: | |
| - 'main' | |
| tags: | |
| - 'v*' | |
| pull_request: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.ref }} | |
| cancel-in-progress: true | |
| permissions: {} | |
| env: | |
| VERSION: ${{ github.ref }} | |
| jobs: | |
| prepare: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| outputs: | |
| platforms: ${{ steps.platforms.outputs.platforms }} | |
| steps: | |
| - name: checkout | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| - name: determine build platforms | |
| id: platforms | |
| run: | | |
| echo platforms=$(docker buildx bake binary-cross --print | jq -cr '.target."binary-cross".platforms') >> $GITHUB_OUTPUT | |
| - name: print platforms | |
| run: echo ${{ steps.platforms.outputs.platforms }} | |
| lint: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| checks: write | |
| contents: read | |
| pull-requests: read | |
| steps: | |
| - name: checkout | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| - name: setup go | |
| uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0 | |
| with: | |
| go-version: "^1.25" | |
| - name: check dependencies | |
| run: | | |
| go mod tidy | |
| git diff --exit-code go.mod | |
| - name: lint | |
| uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0 | |
| build: | |
| needs: prepare | |
| runs-on: blacksmith-4vcpu-ubuntu-2404 | |
| strategy: | |
| matrix: | |
| platform: ${{fromJson(needs.prepare.outputs.platforms)}} | |
| fail-fast: false | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: checkout | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| - name: set platform pair | |
| id: platform | |
| run: | | |
| platform=${{ matrix.platform }} | |
| echo "pair=${platform//\//-}" >> $GITHUB_OUTPUT | |
| - name: setup qemu | |
| uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0 | |
| - name: setup buildx | |
| uses: useblacksmith/setup-docker-builder@33fed32c1ba8775f20366ec9e8d0cd9fe8fc1dd3 # v1.3.0 | |
| - name: build binaries | |
| uses: docker/bake-action@5be5f02ff8819ecd3092ea6b2e6261c31774f2b4 # v6.10.0 | |
| with: | |
| source: . | |
| targets: binary-cross | |
| set: | | |
| *.platform=${{ matrix.platform }} | |
| - name: list artifacts | |
| run: ls -alh ./build | |
| - name: upload artifacts | |
| uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 | |
| with: | |
| name: wpm-${{ steps.platform.outputs.pair }} | |
| path: ./build/wpm-* | |
| if-no-files-found: error | |
| - name: s3 upload | |
| if: ${{ github.ref_type == 'branch' && github.actor != 'dependabot[bot]' }} | |
| run: aws s3 cp build/ s3://wpm-cli-builds/${{ github.event.number && github.event.number != null && github.event.number || 'latest' }}/ --exclude "*" --include "wpm-*" --recursive --endpoint-url ${{ secrets.S3_ENDPOINT_URL }} --region auto --checksum-algorithm CRC32 | |
| env: | |
| AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| pr-comment: | |
| needs: [prepare, build] | |
| runs-on: ubuntu-latest | |
| if: ${{ github.head_ref && github.head_ref != null && github.actor != 'dependabot[bot]' }} | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| steps: | |
| - name: prepare | |
| id: find-existing-comment | |
| uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd #v8.0.0 | |
| with: | |
| script: | | |
| return (await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| })).data.find((comment) => comment.body.includes('wpm cli builds'))?.id || null | |
| - name: comment body | |
| id: comment-body | |
| uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd #v8.0.0 | |
| with: | |
| script: | | |
| const platforms = JSON.parse(${{ toJson(needs.prepare.outputs.platforms) }}) | |
| const builds = platforms.map((platform) => { | |
| const platformPair = platform.split('/') | |
| const buildPath = `wpm-${platformPair[0]}-${platformPair[1]}${platformPair[2] ? `-v${platformPair[2]}` : ''}` | |
| const buildUrl = `https://pub-bea4f3d05c4f49e0b54ccf1dad0da103.r2.dev/${{ github.event.number }}/${buildPath}${platformPair[0] === 'windows' ? '.exe' : ''}` | |
| const spec = `${platformPair[0]}/${platformPair[1]}${platformPair[2] ? `/${platformPair[2]}` : ''}` | |
| return `- \`${spec}\` - [\`build\`](${buildUrl})` | |
| }).join('\n') | |
| return `:package: wpm cli builds :package:\n${builds}\n` | |
| - name: create comment | |
| if: ${{ steps.find-existing-comment.outputs.result == 'null' }} | |
| uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd #v8.0.0 | |
| with: | |
| script: | | |
| github.rest.issues.createComment({ | |
| repo: context.repo.repo, | |
| owner: context.repo.owner, | |
| issue_number: context.issue.number, | |
| body: ${{ steps.comment-body.outputs.result }}, | |
| }); | |
| - name: update comment | |
| if: ${{ steps.find-existing-comment.outputs.result != 'null' }} | |
| uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd #v8.0.0 | |
| with: | |
| script: | | |
| github.rest.issues.updateComment({ | |
| repo: context.repo.repo, | |
| owner: context.repo.owner, | |
| body: ${{ steps.comment-body.outputs.result }}, | |
| comment_id: ${{ steps.find-existing-comment.outputs.result }}, | |
| }); | |
| release: | |
| needs: [prepare, build] | |
| runs-on: blacksmith-8vcpu-ubuntu-2404 | |
| if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }} | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - name: checkout | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| - name: setup qemu | |
| uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0 | |
| - name: Setup Blacksmith Builder | |
| uses: useblacksmith/setup-docker-builder@33fed32c1ba8775f20366ec9e8d0cd9fe8fc1dd3 # v1.3.0 | |
| - name: docker login | |
| uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0 | |
| with: | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: generate image meta | |
| id: meta | |
| uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0 | |
| with: | |
| images: | | |
| ${{ github.repository }} | |
| tags: | | |
| type=ref,event=tag | |
| type=edge | |
| bake-target: meta-helper | |
| - name: build and push images | |
| uses: docker/bake-action@5be5f02ff8819ecd3092ea6b2e6261c31774f2b4 # v6.10.0 | |
| with: | |
| source: . | |
| files: | | |
| ./docker-bake.hcl | |
| ${{ steps.meta.outputs.bake-file }} | |
| targets: image-cross | |
| push: true | |
| - name: download artifacts | |
| uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 #v7.0.0 | |
| with: | |
| path: ./build | |
| pattern: wpm-* | |
| merge-multiple: true | |
| - name: generate checksums | |
| working-directory: ./build | |
| run: | | |
| find . -type f -print0 | sort -z | xargs -r0 shasum -a 256 -b | sed 's# \*\./# *#' > $RUNNER_TEMP/checksums.txt | |
| shasum -a 256 -U -c $RUNNER_TEMP/checksums.txt | |
| mv $RUNNER_TEMP/checksums.txt . | |
| cat checksums.txt | while read sum file; do | |
| echo "$sum $file" > ${file#\*}.sha256 | |
| done | |
| - name: draft release | |
| id: draft-release | |
| uses: release-drafter/release-drafter@b1476f6e6eb133afa41ed8589daba6dc69b4d3f5 # v6.1.0 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: upload release assets | |
| uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd #v8.0.0 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| let uploadUrl = '${{ steps.draft-release.outputs.upload_url }}'; | |
| const templateMarkerPos = uploadUrl.indexOf("{"); | |
| if (templateMarkerPos !== -1) { | |
| uploadUrl = uploadUrl.substring(0, templateMarkerPos); | |
| } | |
| const files = fs.readdirSync('./build').map((file) => `./build/${file}`) | |
| for (const file of files) { | |
| const name = file.replace('./build/', '') | |
| const response = await github.request({ | |
| method: 'POST', | |
| url: uploadUrl + `?name=${name}`, | |
| headers: { | |
| 'content-length': fs.statSync(file).size, | |
| 'authorization': `token ${process.env.GITHUB_TOKEN}`, | |
| 'content-type': name.endsWith('.txt') || name.endsWith('.sha256') ? 'text/plain' : 'application/octet-stream', | |
| }, | |
| name, | |
| data: fs.readFileSync(file), | |
| }); | |
| if (response.status !== 201) { | |
| throw new Error(`failed to upload ${name}`) | |
| } | |
| core.info(`uploaded ${name}`) | |
| } |