Skip to content

Commit 270b4fa

Browse files
committed
ci: automate tagged releases
1 parent ca69df6 commit 270b4fa

2 files changed

Lines changed: 124 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: Release tag matching the package version (for example, v0.1.0)
8+
required: true
9+
type: string
10+
11+
permissions:
12+
contents: read
13+
14+
concurrency:
15+
group: release-${{ inputs.tag }}
16+
cancel-in-progress: false
17+
18+
jobs:
19+
validate:
20+
name: Validate release
21+
if: github.ref == 'refs/heads/master'
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0
28+
29+
- uses: leanprover/lean-action@v1
30+
with:
31+
build-args: Binary Test
32+
check-reservoir-eligibility: true
33+
34+
- name: Verify release tag
35+
env:
36+
RELEASE_TAG: ${{ inputs.tag }}
37+
run: |
38+
package_version="$(lake reservoir-config | jq -r '.version')"
39+
if [[ "${RELEASE_TAG}" != "v${package_version}" ]]; then
40+
echo "release tag ${RELEASE_TAG} does not match package version v${package_version}" >&2
41+
exit 1
42+
fi
43+
if git ls-remote --exit-code --tags origin "refs/tags/${RELEASE_TAG}" >/dev/null 2>&1; then
44+
echo "release tag ${RELEASE_TAG} already exists" >&2
45+
exit 1
46+
fi
47+
48+
build-archives:
49+
name: Build archive (${{ matrix.name }})
50+
needs: validate
51+
strategy:
52+
fail-fast: false
53+
matrix:
54+
include:
55+
- name: Linux x86-64
56+
os: ubuntu-latest
57+
- name: macOS x86-64
58+
os: macos-15-intel
59+
- name: macOS ARM64
60+
os: macos-15
61+
- name: Windows x86-64
62+
os: windows-latest
63+
runs-on: ${{ matrix.os }}
64+
65+
steps:
66+
- uses: actions/checkout@v4
67+
68+
- uses: leanprover/lean-action@v1
69+
with:
70+
build-args: Binary
71+
test: false
72+
use-github-cache: false
73+
74+
- name: Pack Lake build archive
75+
run: lake pack
76+
77+
- name: Stage Lake build archive
78+
uses: actions/upload-artifact@v4
79+
with:
80+
name: release-${{ runner.os }}-${{ runner.arch }}
81+
path: .lake/binary-*.tar.gz
82+
if-no-files-found: error
83+
include-hidden-files: true
84+
85+
publish:
86+
name: Publish release
87+
needs: build-archives
88+
runs-on: ubuntu-latest
89+
permissions:
90+
contents: write
91+
92+
steps:
93+
- uses: actions/checkout@v4
94+
with:
95+
fetch-depth: 0
96+
97+
- name: Download Lake build archives
98+
uses: actions/download-artifact@v4
99+
with:
100+
pattern: release-*
101+
path: dist
102+
merge-multiple: true
103+
104+
- name: Create tag and GitHub release
105+
env:
106+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
107+
RELEASE_TAG: ${{ inputs.tag }}
108+
run: |
109+
git config user.name "github-actions[bot]"
110+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
111+
git tag -a "${RELEASE_TAG}" "${GITHUB_SHA}" -m "binary ${RELEASE_TAG}"
112+
git push origin "${RELEASE_TAG}"
113+
gh release create "${RELEASE_TAG}" dist/*.tar.gz \
114+
--verify-tag \
115+
--generate-notes \
116+
--title "${RELEASE_TAG}"
117+
for archive in dist/*.tar.gz; do
118+
asset="$(basename "${archive}")"
119+
url="https://github.com/${GITHUB_REPOSITORY}/releases/download/${RELEASE_TAG}/${asset}"
120+
curl --fail --head --location --retry 5 --retry-all-errors "${url}"
121+
echo "- ${url}" >> "${GITHUB_STEP_SUMMARY}"
122+
done

lakefile.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ open Lake DSL
33

44
package "binary" where
55
version := v!"0.1.0"
6+
releaseRepo := "https://github.com/Lean-zh/binary"
7+
preferReleaseBuild := true
68

79
@[default_target]
810
lean_lib Binary where

0 commit comments

Comments
 (0)