Skip to content

Commit a0b156f

Browse files
authored
Merge pull request #8 from awnion/release-workflow-v2
rework release workflow
2 parents 41aa5e7 + f36aa23 commit a0b156f

8 files changed

Lines changed: 280 additions & 143 deletions

File tree

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: Fork release
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths: [private-build-plans.toml]
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
permissions:
13+
contents: write
14+
packages: write
15+
16+
env:
17+
REGISTRY: ghcr.io
18+
IMAGE: ghcr.io/${{ github.repository }}
19+
FONT_NAME: afio
20+
21+
jobs:
22+
build:
23+
if: github.repository != 'awnion/custom-iosevka-nerd-font'
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v6
27+
28+
- uses: docker/setup-buildx-action@v4
29+
30+
- uses: docker/login-action@v4
31+
with:
32+
registry: ${{ env.REGISTRY }}
33+
username: ${{ github.actor }}
34+
password: ${{ secrets.GITHUB_TOKEN }}
35+
36+
- id: sha
37+
run: echo "short=${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"
38+
39+
- id: meta
40+
uses: docker/metadata-action@v6
41+
with:
42+
images: ${{ env.IMAGE }}
43+
tags: |
44+
type=raw,value=sha-${{ steps.sha.outputs.short }}
45+
46+
- uses: docker/build-push-action@v7
47+
with:
48+
context: .
49+
push: true
50+
tags: ${{ steps.meta.outputs.tags }}
51+
cache-from: type=gha
52+
cache-to: type=gha,mode=max
53+
54+
- name: Build font
55+
env:
56+
IMAGE_REF: ${{ env.IMAGE }}:sha-${{ steps.sha.outputs.short }}
57+
run: ./build.sh
58+
59+
- name: Create or update latest pre-release
60+
env:
61+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
run: |
63+
mv _output/${FONT_NAME}-*.zip "_output/${FONT_NAME}-latest.zip"
64+
65+
gh release create latest \
66+
"_output/${FONT_NAME}-latest.zip" \
67+
-R "${{ github.repository }}" \
68+
--prerelease \
69+
--title "Latest build" \
70+
--notes "$(cat <<'NOTES'
71+
## Install latest build
72+
73+
### Download
74+
75+
```bash
76+
curl -fsSLO https://github.com/${{ github.repository }}/releases/download/latest/${FONT_NAME}-latest.zip
77+
```
78+
79+
### Install (macOS)
80+
81+
```bash
82+
curl -fsSLO https://github.com/${{ github.repository }}/releases/download/latest/${FONT_NAME}-latest.zip
83+
unzip -o ${FONT_NAME}-latest.zip -d ~/Library/Fonts/
84+
```
85+
86+
### Install (Linux)
87+
88+
```bash
89+
curl -fsSLO https://github.com/${{ github.repository }}/releases/download/latest/${FONT_NAME}-latest.zip
90+
mkdir -p ~/.local/share/fonts
91+
unzip -o ${FONT_NAME}-latest.zip -d ~/.local/share/fonts/
92+
fc-cache -fv
93+
```
94+
95+
---
96+
97+
> This is an automated pre-release from the latest commit on `main`.
98+
> For stable versions, see [tagged releases](https://github.com/${{ github.repository }}/releases).
99+
NOTES
100+
)" 2>/dev/null || \
101+
gh release upload latest \
102+
"_output/${FONT_NAME}-latest.zip" \
103+
-R "${{ github.repository }}" \
104+
--clobber

.github/workflows/pr.yaml

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ concurrency:
88
cancel-in-progress: true
99

1010
permissions:
11-
contents: read
11+
contents: write
1212
packages: write
1313

1414
env:
@@ -17,6 +17,33 @@ env:
1717
FONT_NAME: afio
1818

1919
jobs:
20+
rc-checks:
21+
if: startsWith(github.head_ref, 'v') && endsWith(github.head_ref, '-rc')
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v6
25+
with:
26+
ref: ${{ github.event.pull_request.head.sha }}
27+
28+
- name: Validate VERSION matches branch
29+
run: |
30+
VERSION=$(cat VERSION | tr -d '[:space:]')
31+
BRANCH="${{ github.head_ref }}"
32+
EXPECTED="v${VERSION}-rc"
33+
if [ "$BRANCH" != "$EXPECTED" ]; then
34+
echo "::error::VERSION file (${VERSION}) does not match branch ${BRANCH} (expected ${EXPECTED})"
35+
exit 1
36+
fi
37+
38+
- name: Check release notes in PR description
39+
env:
40+
PR_BODY: ${{ github.event.pull_request.body }}
41+
run: |
42+
if [ -z "$PR_BODY" ]; then
43+
echo "::error::PR description is required for RC branches (used as release notes)"
44+
exit 1
45+
fi
46+
2047
build-image:
2148
runs-on: ubuntu-latest
2249
outputs:
@@ -140,3 +167,44 @@ jobs:
140167
with:
141168
name: visual-generated
142169
path: _generated/*.png
170+
171+
prerelease:
172+
if: startsWith(github.head_ref, 'v') && endsWith(github.head_ref, '-rc')
173+
needs: [rc-checks, visual-check]
174+
runs-on: ubuntu-latest
175+
steps:
176+
- uses: actions/checkout@v6
177+
with:
178+
ref: ${{ github.event.pull_request.head.sha }}
179+
180+
- name: Extract version
181+
run: |
182+
VERSION=$(cat VERSION | tr -d '[:space:]')
183+
echo "VERSION=${VERSION}" >> "$GITHUB_ENV"
184+
185+
- name: Download font artifact
186+
uses: actions/download-artifact@v4
187+
with:
188+
name: font-build
189+
path: _output
190+
191+
- name: Create pre-release
192+
env:
193+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
194+
SHA: ${{ github.event.pull_request.head.sha }}
195+
PR_BODY: ${{ github.event.pull_request.body }}
196+
run: |
197+
RC_TAG="v${VERSION}-rc.${{ github.run_number }}"
198+
199+
mv _output/${FONT_NAME}-*.zip "_output/${FONT_NAME}-${RC_TAG}.zip"
200+
201+
gh api "repos/${{ github.repository }}/git/refs" \
202+
-f ref="refs/tags/${RC_TAG}" \
203+
-f sha="${SHA}"
204+
205+
gh release create "$RC_TAG" \
206+
"_output/${FONT_NAME}-${RC_TAG}.zip" \
207+
-R "${{ github.repository }}" \
208+
--prerelease \
209+
--title "$RC_TAG" \
210+
--notes "$PR_BODY"

.github/workflows/prerelease.yaml

Lines changed: 0 additions & 91 deletions
This file was deleted.

0 commit comments

Comments
 (0)