wip: new release process improvements - docs, drafts, changelog #94
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 | |
on: | |
push: | |
branches: | |
- release/v* | |
- releases | |
paths: | |
- build/version.go | |
pull_request: | |
branches: | |
- release/v* | |
- releases | |
- ipdx/* | |
paths: | |
- build/version.go | |
workflow_dispatch: | |
inputs: | |
publish: | |
description: 'Publish the release' | |
required: false | |
default: 'false' | |
draft: | |
description: 'Create a draft release' | |
required: false | |
default: 'true' | |
target_commitish: | |
description: 'The commitish value that determines where the Git tag is created from' | |
required: false | |
default: '' | |
ref: | |
description: 'The ref to checkout before building' | |
required: false | |
default: '' | |
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 | |
- if: github.event.inputs.ref | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.event.inputs.ref }} | |
- 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 | sub("^refs/heads/"; "")) == "ipdx/release-automation" or env.GITHUB_EVENT_NAME == "workflow_dispatch")))' | | |
jq -c '.' | xargs -I {} -0 echo "projects={}" | | |
tee -a $GITHUB_OUTPUT | |
build: | |
needs: [check] | |
if: false | |
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 | |
- if: github.event.inputs.ref | |
uses: actions/checkout@v4 | |
with: | |
submodules: 'recursive' | |
ref: ${{ github.event.inputs.ref }} | |
- 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] | |
if: needs.check.outputs.projects != '[]' | |
name: Release ${{ matrix.project }} [publish=${{ github.event.inputs.publish == 'true' || github.event_name != 'workflow_dispatch' }}] | |
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.inputs.publish == 'true' || github.event_name != 'workflow_dispatch' }} | |
IS_DRAFT: ${{ github.event.inputs.draft == 'true' || github.event_name == 'pull_request' }} | |
GOPATH: ${{ github.workspace }} | |
defaults: | |
run: | |
working-directory: github.com/filecoin-project/lotus | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: 'recursive' | |
fetch-depth: 0 | |
path: github.com/filecoin-project/lotus | |
- 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 | |
- run: | | |
mkdir linux_amd64_v1 | |
mkdir darwin_amd64_v1 | |
mkdir darwin_arm64 | |
if [[ "${{ matrix.project}}" == "node" ]]; then | |
touch linux_amd64_v1/lotus | |
touch darwin_amd64_v1/lotus | |
touch darwin_arm64/lotus | |
else | |
touch linux_amd64_v1/lotus-miner | |
touch linux_amd64_v1/lotus-worker | |
touch darwin_amd64_v1/lotus-miner | |
touch darwin_amd64_v1/lotus-worker | |
touch darwin_arm64/lotus-miner | |
touch darwin_arm64/lotus-worker | |
fi | |
- uses: ./github.com/filecoin-project/lotus/.github/actions/install-go | |
- uses: ipfs/download-ipfs-distribution-action@v1 | |
with: | |
name: kubo | |
version: v0.16.0 | |
cache: false | |
- name: Install yq | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
run: | | |
gh release --repo mikefarah/yq download v4.44.2 -p yq_linux_amd64 | |
sudo mv yq_linux_amd64 /usr/bin/yq | |
sudo chmod +x /usr/bin/yq | |
- if: env.IS_DRAFT == 'false' | |
run: yq -i '.release.draft = false' '.goreleaser.yaml' | |
- if: env.PUBLISH == 'true' && env.IS_DRAFT == 'false' && fromJSON(steps.project.outputs.config).latest && !fromJSON(steps.project.outputs.config).prerelease | |
run: yq -i '.brews.[0].skip_upload = false' '.goreleaser.yaml' | |
- if: matrix.project == 'node' && fromJSON(steps.project.outputs.config).latest | |
run: yq -i '.release.make_latest = true' '.goreleaser.yaml' | |
- if: matrix.project == 'node' | |
env: | |
BREW_INSTALL: | | |
bin.install "lotus" | |
BREW_TEST: | | |
system "#{bin}/lotus --version" | |
run: | | |
yq -i '(.builds[] | select(.id == "lotus")).skip = false' '.goreleaser.yaml' | |
yq -i '.brews[0].install = strenv(BREW_INSTALL)' '.goreleaser.yaml' | |
yq -i '.brews[0].test = strenv(BREW_TEST)' '.goreleaser.yaml' | |
- if: matrix.project == 'miner' | |
env: | |
BREW_INSTALL: | | |
bin.install "lotus-miner" | |
bin.install "lotus-worker" | |
BREW_TEST: | | |
system "#{bin}/lotus-miner --version" | |
system "#{bin}/lotus-worker --version" | |
run: | | |
yq -i '(.builds[] | select(.id == "lotus-miner" or .id == "lotus-worker")).skip = false' '.goreleaser.yaml' | |
yq -i '.brews[0].install = strenv(BREW_INSTALL)' '.goreleaser.yaml' | |
yq -i '.brews[0].test = strenv(BREW_TEST)' '.goreleaser.yaml' | |
- run: sudo apt update && sudo apt install -y zsh | |
- id: changelog | |
env: | |
tag: ${{ fromJSON(steps.project.outputs.config).tag }} | |
head: ${{ github.event.inputs.ref || github.sha }} | |
base: ${{ fromJSON(steps.project.outputs.config).previous }} | |
run: | | |
echo "content<<EOF" | tee -a $GITHUB_OUTPUT | |
echo "# $tag" | tee -a $GITHUB_OUTPUT | |
echo "" | tee -a $GITHUB_OUTPUT | |
csplit --digits=4 --quiet --elide-empty-files CHANGELOG.md '/^# /' '{*}' | |
# Checking the files in reverse order to get to the UNRELEASED section last | |
for file in $(ls -r xx*); do | |
if grep -q "^# $tag " $file || grep -q "^# UNRELEASED" $file; then | |
tail -n +3 $file | tee -a $GITHUB_OUTPUT | |
break | |
fi | |
done | |
if [[ "$base" != '' ]]; then | |
./scripts/mkreleaselog "$base" "$head" | tee -a $GITHUB_OUTPUT | |
fi | |
echo "EOF" | tee -a $GITHUB_OUTPUT | |
- env: | |
tag: ${{ fromJSON(steps.project.outputs.config).tag }} | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git tag -a $tag -m "Release $tag" | |
- uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5.0.0 | |
with: | |
distribution: goreleaser-pro | |
version: 2.0.1 | |
args: release --clean --skip=validate ${{ env.PUBLISH == 'false' && '--snapshot' || '' }} --verbose | |
workdir: github.com/filecoin-project/lotus | |
env: | |
PROJECT_NAME: ${{ matrix.project == 'node' && 'lotus' || format('lotus-{0}', matrix.project) }} | |
GITHUB_TOKEN: ${{ env.PUBLISH == 'true' && (secrets.GORELEASER_GITUB_TOKEN || github.token) || '' }} | |
GORELEASER_KEY: ${{ env.PUBLISH == 'true' && secrets.GORELEASER_KEY || '' }} | |
TAG: ${{ fromJSON(steps.project.outputs.config).tag }} | |
TAG_PREFIX: ${{ matrix.project == 'node' && 'v' || format('{0}/', matrix.project) }} | |
VERSION: ${{ fromJSON(steps.project.outputs.config).version }} | |
IS_PRERELEASE: ${{ fromJSON(steps.project.outputs.config).prerelease }} | |
TARGET_COMMITISH: ${{ github.event.inputs.target_commitish || (github.event_name == 'pull_request' && github.event.pull_request.base.ref || github.sha) }} | |
HEADER: | | |
${{ steps.changelog.outputs.content }} | |
<!-- | |
FOOTER: | | |
--> | |
- run: ./scripts/generate-checksums.sh | |
- if: env.PUBLISH == 'true' && env.IS_DRAFT == 'false' | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
TAG: ${{ fromJSON(steps.project.outputs.config).tag }} | |
run: ./scripts/publish-checksums.sh |