Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ci: automate the new release process #12096

Merged
merged 23 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d3f3d52
feat: ci: automate the new release process
galargh Jun 16, 2024
fbb7517
Merge remote-tracking branch 'origin/master' into ipdx/release-automa…
galargh Jun 21, 2024
c78b802
docs: document the usage and purpose of the release cmd
galargh Jun 21, 2024
f0abec8
docs: update the RELEASE_ISSUE_TEMPLATE to reflect the automation add…
galargh Jun 21, 2024
97fb595
fix: setting the prerelease checkbox in goreleaser
galargh Jun 21, 2024
e90f027
fix: when the release workflow is triggered automatically
galargh Jun 21, 2024
ba06784
fix: docker workflow triggers
galargh Jun 21, 2024
e960dfc
docs: update the release issue template
galargh Jun 21, 2024
46bc707
fix: go fmt and go mod tidy
galargh Jun 21, 2024
730f470
Merge remote-tracking branch 'origin/master' into ipdx/release-automa…
galargh Jun 26, 2024
2428f62
chore: update the release automation after initial testing
galargh Jun 26, 2024
2102091
docs: update README of the release tool
galargh Jun 26, 2024
253ab88
chore: fix go imports
galargh Jun 26, 2024
72254f8
fix: apply fixes from the testing branches
galargh Jun 27, 2024
2df032e
docs: update the release issue template
galargh Jun 27, 2024
438ecba
chore: resolve release automation todos
galargh Jun 27, 2024
86f67ea
feat: ci: remove gorelease, create drafts and automate release notes
galargh Jul 9, 2024
aad564f
chore: ci: allow using pat for tag creation during release
galargh Jul 15, 2024
1bda8d9
chore: docs: apply suggestions from code review
galargh Jul 15, 2024
1b9f812
Merge remote-tracking branch 'origin/master' into ipdx/release-automa…
galargh Jul 15, 2024
c1d8638
chore: ci: stop using the releases branch
galargh Jul 17, 2024
55d83f0
chore: ci: preserve release body
galargh Jul 17, 2024
914b17b
chore: ci: apply fixes discovered through testing in a fork
galargh Jul 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 13 additions & 16 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
name: Docker

# TODO(p2): Restore worfklow_dispatch trigger
on:
push:
branches:
- master
- release/*
tags:
- v*
pull_request:
branches:
- master
- release/v*
- releases
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
inputs:
ref:
description: The GitHub ref (e.g. refs/tags/v1.0.0) to release
required: false

defaults:
run:
Expand All @@ -24,7 +24,7 @@ permissions:

jobs:
docker:
name: Docker (${{ matrix.image }} / ${{ matrix.network }}) [publish=${{ (inputs.ref || github.ref) == 'refs/heads/master' || startsWith(inputs.ref || github.ref, 'refs/tags/') }}]
name: Docker (${{ matrix.image }} / ${{ matrix.network }}) [publish=${{ github.event_name != 'pull_request' }}]
galargh marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -40,13 +40,13 @@ jobs:
- image: lotus
network: mainnet
env:
PUBLISH: ${{ github.ref == 'refs/heads/master' || startsWith(inputs.ref || github.ref, 'refs/tags/') }}
PUBLISH: ${{ github.event_name != 'pull_request' }}
steps:
- id: channel
env:
IS_MASTER: ${{ (inputs.ref || github.ref) == 'refs/heads/master' }}
IS_TAG: ${{ startsWith(inputs.ref || github.ref, 'refs/tags/') }}
IS_RC: ${{ contains(inputs.ref || github.ref, '-rc') }}
IS_MASTER: ${{ github.ref == 'refs/heads/master' }}
IS_TAG: ${{ startsWith(github.ref, 'refs/tags/') }}
IS_RC: ${{ contains(github.ref, '-rc') }}
IS_SCHEDULED: ${{ github.event_name == 'schedule' }}
run: |
channel=''
Expand All @@ -67,12 +67,9 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
ref: ${{ inputs.ref || github.ref }}
- id: git
env:
REF: ${{ inputs.ref || github.ref }}
run: |
ref="${REF#refs/heads/}"
ref="${GITHUB_REF#refs/heads/}"
ref="${ref#refs/tags/}"
sha="$(git rev-parse --short HEAD)"
echo "ref=$ref" | tee -a "$GITHUB_OUTPUT"
Expand All @@ -86,7 +83,7 @@ jobs:
images: filecoin/${{ matrix.image }}
tags: |
type=raw,enable=${{ steps.channel.outputs.channel != '' }},value=${{ steps.channel.outputs.channel }}
type=raw,enable=${{ startsWith(inputs.ref || github.ref, 'refs/tags/') }},value=${{ steps.git.outputs.ref }}
type=raw,enable=${{ startsWith(github.ref, 'refs/tags/') }},value=${{ steps.git.outputs.ref }}
type=raw,value=${{ steps.git.outputs.sha }}
flavor: |
latest=false
Expand Down
173 changes: 118 additions & 55 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
name: Release

# TODO(p2): Restore worfklow_dispatch trigger
on:
push:
branches:
- ci/*
- release/*
tags:
- v*
workflow_dispatch:
inputs:
ref:
description: The GitHub ref (e.g. refs/tags/v1.0.0) to release
required: false
- release/v*
- releases
paths:
- build/version.go
pull_request:
branches:
- release/v*
- releases
paths:
- build/version.go

defaults:
run:
Expand All @@ -21,12 +23,52 @@ 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: |
projects=()
for project in node miner; do
echo "project=$project"
current_version=$(go run cmd/release/main.go --json $project version | jq -r .msg)
echo "${project}_current_version=$current_version"
if [[ $current_version =~ -dev$ ]]; then
echo "Skipping $project because it's a dev version"
continue
fi
if [[ $current_version =~ -rc$ && "$TARGET_REF" == 'refs/heads/releases' ]]; then
echo "Skipping $project because it's an RC version on the releases branch"
continue
fi
if [[ "$project" == "node" ]]; then
current_version_exists=(git tag -l 'v*' | grep -q $current_version)
else
current_version_exists=(git tag -l '$project/v*' | grep -q $current_version)
fi
echo "${project}_current_version_exists=$current_version_exists"
if [[ ! $current_version_exists ]]; then
projects+=($project)
galargh marked this conversation as resolved.
Show resolved Hide resolved
fi
done
echo "projects=$(echo "${projects[@]}" | jq -c .)" | tee -a $GITHUB_OUTPUT
build:
name: Build (${{ matrix.os }}/${{ matrix.arch }})
needs: [check]
if: needs.check.outputs.projects != '[]'
name: Build ${{ matrix.project }} (${{ matrix.os }}/${{ matrix.arch }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
project: ${{ fromJSON(needs.check.outputs.projects) }}
include:
- runner: ubuntu-latest
os: Linux
Expand All @@ -46,96 +88,117 @@ jobs:
echo "::error title=Unexpected Runner::Expected $OS/$ARCH, got $RUNNER_OS/$RUNNER_ARCH"
exit 1
fi
- uses: actions/checkout@v4
with:
path: actions
- uses: actions/checkout@v4
with:
submodules: 'recursive'
ref: ${{ inputs.ref || github.ref }}
path: lotus
- uses: ./actions/.github/actions/install-system-dependencies
- uses: ./actions/.github/actions/install-go
with:
working-directory: lotus
- uses: ./.github/actions/install-system-dependencies
- uses: ./.github/actions/install-go
- env:
GITHUB_TOKEN: ${{ github.token }}
run: make deps lotus lotus-miner lotus-worker
working-directory: lotus
- if: runner.os == 'macOS'
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: matrix.project == 'lotus' && runner.os == 'macOS'
galargh marked this conversation as resolved.
Show resolved Hide resolved
run: otool -hv lotus
working-directory: lotus
- env:
INPUTS_REF: ${{ inputs.ref }}
run: |
export GITHUB_REF=${INPUTS_REF:-$GITHUB_REF}
../actions/scripts/version-check.sh ./lotus
working-directory: lotus
- uses: actions/upload-artifact@v4
with:
name: lotus-${{ matrix.os }}-${{ matrix.arch }}
name: lotus-${{ matrix.project }}-${{ matrix.os }}-${{ matrix.arch }}
path: |
lotus/lotus
lotus/lotus-miner
lotus/lotus-worker
release:
name: Release [publish=${{ startsWith(inputs.ref || github.ref, 'refs/tags/') }}]
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
needs: [build]
strategy:
fail-fast: false
matrix:
project: ${{ fromJSON(needs.check.outputs.projects) }}
env:
PUBLISH: ${{ startsWith(inputs.ref || github.ref, 'refs/tags/') }}
PUBLISH: ${{ github.event_name != 'pull_request' }}
steps:
- uses: actions/checkout@v4
with:
path: actions
- uses: actions/checkout@v4
with:
submodules: 'recursive'
fetch-depth: 0
path: lotus
ref: ${{ inputs.ref || github.ref }}
- uses: actions/download-artifact@v4
with:
name: lotus-Linux-X64
name: lotus-${{ matrix.project }}-Linux-X64
path: linux_amd64_v1
- uses: actions/download-artifact@v4
with:
name: lotus-macOS-X64
name: lotus-${{ matrix.project }}-macOS-X64
path: darwin_amd64_v1
- uses: actions/download-artifact@v4
with:
name: lotus-macOS-ARM64
name: lotus-${{ matrix.project }}-macOS-ARM64
path: darwin_arm64
- uses: ./actions/.github/actions/install-go
with:
working-directory: lotus
- uses: ./.github/actions/install-go
- uses: ipfs/download-ipfs-distribution-action@v1
with:
name: kubo
version: v0.16.0
- id: meta
run: |
version="$(go run cmd/release/main.go --json ${{ matrix.project }} version | jq -r .msg)"
if [[ "${{ matrix.project}}" == "miner" ]]; then
tag="miner/$version"
latest="$(git tag -l 'miner/v*' | sort -V | tail -n1)"
elif [[ "${{ matrix.project}}" == "node" ]]; then
tag="$version"
latest="$(git tag -l 'v*' | sort -V | tail -n1)"
galargh marked this conversation as resolved.
Show resolved Hide resolved
else
echo "::error title=Unknown Project::${{ matrix.project }}"
exit 1
fi
latest="$(echo -e "$latest\n$version" | sort -V | tail -n1)"
echo "version=$version" | tee -a $GITHUB_OUTPUT
echo "latest=$latest" | tee -a $GITHUB_OUTPUT
echo "tag=$tag" | tee -a $GITHUB_OUTPUT
- env:
expected: ${{ steps.meta.outputs.version }}
run: |
for dir in linux_amd64_v1 darwin_amd64_v1 darwin_arm64; do
for bin in lotus lotus-miner lotus-worker; do
if [[ -f $dir/$bin ]]; then
actual=$(./$dir/$bin --version)
if [[ "$actual" != "$expected" ]]; then
echo "::error title=Version Mismatch::Expected $expected, got $actual ($dir/$bin)"
galargh marked this conversation as resolved.
Show resolved Hide resolved
exit 1
fi
fi
done
done
- uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5.0.0
with:
distribution: goreleaser-pro
version: 2.0.1
args: release --clean ${{ env.PUBLISH == 'false' && '--snapshot' || '' }}
workdir: lotus
env:
GITHUB_TOKEN: ${{ env.PUBLISH == 'true' && secrets.GORELEASER_GITUB_TOKEN || github.token || '' }}
GORELEASER_KEY: ${{ env.PUBLISH == 'true' && secrets.GORELEASER_KEY || '' }}
- env:
INPUTS_REF: ${{ inputs.ref }}
run: |
export GITHUB_REF=${INPUTS_REF:-$GITHUB_REF}
../actions/scripts/generate-checksums.sh
working-directory: lotus
TAG: ${{ steps.meta.outputs.tag }}
VERSION: ${{ steps.meta.outputs.version }}
IS_LATEST: ${{ steps.meta.outputs.latest == steps.meta.outputs.version }}
IS_DRAFT: ${{ github.event_name == 'pull_request' }}
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 }}
INPUTS_REF: ${{ inputs.ref }}
TAG: ${{ steps.meta.outputs.tag }}
run: |
export GITHUB_REF=${INPUTS_REF:-$GITHUB_REF}
../actions/scripts/publish-checksums.sh
working-directory: lotus
./scripts/publish-checksums.sh
27 changes: 17 additions & 10 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# yaml-language-server: $schema=https://goreleaser.com/static/schema-pro.json
# TODO(p0): Test if templating on boolean values is supported

version: 2

Expand All @@ -8,12 +9,6 @@ universal_binaries:
- id: lotus
replace: true
name_template: lotus
- id: lotus-miner
replace: true
name_template: lotus-miner
- id: lotus-worker
replace: true
name_template: lotus-worker

builds:
- id: lotus
Expand All @@ -32,6 +27,7 @@ builds:
goarch: arm64
prebuilt:
path: '{{ .Env.GITHUB_WORKSPACE }}/{{ .Os }}_{{ .Arch }}{{ with .Amd64 }}_{{ . }}{{ end }}/lotus'
skip: '{{ .Env.PROJECT != "node" }}'
- id: lotus-miner
binary: lotus-miner
builder: prebuilt
Expand All @@ -48,6 +44,7 @@ builds:
goarch: arm64
prebuilt:
path: '{{ .Env.GITHUB_WORKSPACE }}/{{ .Os }}_{{ .Arch }}{{ with .Amd64 }}_{{ . }}{{ end }}/lotus-miner'
skip: '{{ .Env.PROJECT != "miner" }}'
- id: lotus-worker
binary: lotus-worker
builder: prebuilt
Expand All @@ -64,12 +61,13 @@ builds:
goarch: arm64
prebuilt:
path: '{{ .Env.GITHUB_WORKSPACE }}/{{ .Os }}_{{ .Arch }}{{ with .Amd64 }}_{{ . }}{{ end }}/lotus-worker'
skip: '{{ .Env.PROJECT != "miner" }}'

archives:
- id: primary
format: tar.gz
wrap_in_directory: true
name_template: "{{ .ProjectName }}_v{{ .Version }}_{{ .Os }}_{{ .Arch }}"
name_template: "{{ .ProjectName }}_{{ .Env.VERSION }}_{{ .Os }}_{{ .Arch }}"
files:
# this is a dumb but required hack so it doesn't include the default files
# https://github.com/goreleaser/goreleaser/issues/602
Expand All @@ -79,9 +77,18 @@ release:
github:
owner: filecoin-project
name: lotus
prerelease: auto
name_template: "v{{.Version}}"
draft: "{{ .Env.IS_DRAFT }}"
header: "{{ .Env.HEADER }}"
make_latest: "${{ .Env.IS_LATEST }}"
name_template: "{{ .Env.VERSION }}"
prerelease: "${{ .Env.VERSION | strings.hasSuffix '-rc' }}"
replace_existing_artifacts: true
# TODO(p0): Test if not replacing existing drafts updates them instead of failing the release
galargh marked this conversation as resolved.
Show resolved Hide resolved
replace_existing_draft: false
rvagg marked this conversation as resolved.
Show resolved Hide resolved
tag: "{{ .Env.TAG }}"
target_commitish: "{{ .Env.TARGET_COMMITISH }}"

# TODO(p0): Figure out how to perform partial Homebrew updates
brews:
- repository:
owner: filecoin-project
Expand Down Expand Up @@ -110,4 +117,4 @@ checksum:
disable: true

snapshot:
name_template: "{{ .Version }}"
name_template: "{{ .Env.VERSION }}"
Loading
Loading