WIP: testing release automation #61
Workflow file for this run
This file contains 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: Release | |
# TODO(p2): Restore worfklow_dispatch trigger | |
on: | |
push: | |
branches: | |
- ipdx/release-automation-release-v* | |
- ipdx/release-automation-releases | |
paths: | |
- build/version.go | |
pull_request: | |
branches: | |
- ipdx/release-automation-release-v* | |
- ipdx/release-automation-releases | |
paths: | |
- build/version.go | |
defaults: | |
run: | |
shell: bash | |
permissions: | |
contents: read | |
jobs: | |
check: | |
name: Check which projects need to be built | |
runs-on: ubuntu-latest | |
outputs: | |
projects: ${{ steps.projects.outputs.projects }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- id: projects | |
env: | |
TARGET_REF: ${{ github.base_ref || github.ref }} | |
run: | | |
go run cmd/release/main.go --json list-projects | jq -r '.msg' | | |
jq 'map(select(.version | endswith("-dev") | not))' | | |
jq 'map(select(.released | not))' | | |
jq 'map(select(.prerelease != (env.TARGET_REF == "refs/heads/ipdx/release-automation-releases")))' | | |
jq -c '.' | xargs -I {} -0 echo "projects={}" | | |
tee -a $GITHUB_OUTPUT | |
build: | |
needs: [check] | |
if: needs.check.outputs.projects != '[]' | |
name: Build ${{ matrix.project }} (${{ matrix.runner }}) | |
runs-on: ${{ matrix.runner }} | |
strategy: | |
fail-fast: false | |
matrix: | |
project: ${{ fromJSON(needs.check.outputs.projects).*.name }} | |
runner: | |
- ubuntu-latest # Linux X64 | |
- macos-13 # MacOs X64 | |
- macos-14 # MacOS ARM64 | |
steps: | |
- run: echo "Building on $RUNNER_OS/$RUNNER_ARCH" | |
- id: project | |
env: | |
projects: ${{ needs.check.outputs.projects }} | |
name: ${{ matrix.project }} | |
run: | | |
jq -nc 'env.projects | fromjson | map(select(.name == env.name)) | .[0]' | | |
xargs -I {} -0 echo "config={}" | | |
tee -a $GITHUB_OUTPUT | |
- uses: actions/checkout@v4 | |
with: | |
submodules: 'recursive' | |
- uses: ./.github/actions/install-system-dependencies | |
- uses: ./.github/actions/install-go | |
- env: | |
GITHUB_TOKEN: ${{ github.token }} | |
run: make deps | |
- if: matrix.project == 'node' | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
run: make lotus | |
- if: matrix.project == 'miner' | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
run: make lotus-miner lotus-worker | |
- if: runner.os == 'macOS' | |
run: if [[ -f lotus ]]; then otool -hv lotus; fi | |
- env: | |
LOTUS_VERSION_IGNORE_COMMIT: 1 | |
expected: ${{ fromJSON(steps.project.outputs.config).version }} | |
run: | | |
for bin in lotus lotus-miner lotus-worker; do | |
if [[ -f ./$bin ]]; then | |
chmod +x ./$bin | |
actual=$(./$bin --version | cut -d' ' -f3) | |
if [[ "$actual" != "$expected" ]]; then | |
echo "::error title=Version Mismatch::Expected $expected, got $actual (./$bin)" | |
exit 1 | |
fi | |
fi | |
done | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: lotus-${{ matrix.project }}-${{ runner.os }}-${{ runner.arch }} | |
path: | | |
lotus | |
lotus-miner | |
lotus-worker | |
release: | |
needs: [check, build] | |
if: needs.check.outputs.projects != '[]' | |
name: Release [publish=${{ github.event_name != 'pull_request' }}] | |
permissions: | |
# This enables the job to create and/or update GitHub releases | |
contents: write | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
project: ${{ fromJSON(needs.check.outputs.projects).*.name }} | |
env: | |
PUBLISH: ${{ github.event_name != 'pull_request' }} | |
steps: | |
- id: project | |
env: | |
projects: ${{ needs.check.outputs.projects }} | |
name: ${{ matrix.project }} | |
run: | | |
jq -nc 'env.projects | fromjson | map(select(.name == env.name)) | .[0]' | | |
xargs -I {} -0 echo "config={}" | | |
tee -a $GITHUB_OUTPUT | |
- uses: actions/checkout@v4 | |
with: | |
submodules: 'recursive' | |
fetch-depth: 0 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: lotus-${{ matrix.project }}-Linux-X64 | |
path: linux_amd64_v1 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: lotus-${{ matrix.project }}-macOS-X64 | |
path: darwin_amd64_v1 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: lotus-${{ matrix.project }}-macOS-ARM64 | |
path: darwin_arm64 | |
- uses: ./.github/actions/install-go | |
- uses: ipfs/download-ipfs-distribution-action@v1 | |
with: | |
name: kubo | |
version: v0.16.0 | |
# - if: github.event_name != 'pull_request' | |
# uses: mikefarah/yq@f15500b20a1c991c8729870ba60a4dc3524b6a94 # v4.44.2 | |
# with: | |
# cmd: yq -i '.release.draft = false' '.goreleaser.yaml' | |
- if: matrix.project == 'node' | |
uses: mikefarah/yq@f15500b20a1c991c8729870ba60a4dc3524b6a94 # v4.44.2 | |
with: | |
cmd: yq -i '(.builds[] | select(.id == "lotus")).skip = false' '.goreleaser.yaml' | |
- if: matrix.project == 'miner' | |
uses: mikefarah/yq@f15500b20a1c991c8729870ba60a4dc3524b6a94 # v4.44.2 | |
with: | |
cmd: yq -i '(.builds[] | select(.id == "lotus-miner" or .id == "lotus-worker")).skip = false' '.goreleaser.yaml' | |
- uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5.0.0 | |
with: | |
distribution: goreleaser-pro | |
version: 2.0.1 | |
args: release --clean ${{ env.PUBLISH == 'false' && '--snapshot' || '' }} | |
env: | |
PROJECT: ${{ matrix.project }} | |
GITHUB_TOKEN: ${{ env.PUBLISH == 'true' && github.token || '' }} | |
GORELEASER_KEY: ${{ env.PUBLISH == 'true' && secrets.GORELEASER_KEY || '' }} | |
TAG: ${{ fromJSON(steps.project.outputs.config).tag }} | |
VERSION: ${{ fromJSON(steps.project.outputs.config).version }} | |
IS_LATEST: ${{ fromJSON(steps.project.outputs.config).latest }} | |
IS_DRAFT: true # ${{ github.event_name == 'pull_request' }} | |
IS_PRERELEASE: ${{ fromJSON(steps.project.outputs.config).prerelease }} | |
TARGET_COMMITISH: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || github.sha }} | |
HEADER: '' # TODO(p3): Extract release notes from CHANGELOG.md | |
- run: ./scripts/generate-checksums.sh | |
- if: env.PUBLISH == 'true' | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
TAG: ${{ fromJSON(steps.project.outputs.config).tag }} | |
run: ./scripts/publish-checksums.sh |