-
Notifications
You must be signed in to change notification settings - Fork 1
145 lines (133 loc) · 4.06 KB
/
release-build.yml
File metadata and controls
145 lines (133 loc) · 4.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: release-build
on:
push:
tags: ['v*']
permissions:
contents: write
jobs:
build:
name: ${{ matrix.platform }}
strategy:
fail-fast: true
matrix:
include:
- platform: linux-amd64
runner: ubuntu-22.04
os: linux
arch: amd64
ext: tar.gz
exe: ""
- platform: linux-arm64
runner: ubuntu-22.04-arm
os: linux
arch: arm64
ext: tar.gz
exe: ""
- platform: darwin-amd64
runner: macos-15-intel
os: darwin
arch: amd64
ext: tar.gz
exe: ""
- platform: darwin-arm64
runner: macos-15
os: darwin
arch: arm64
ext: tar.gz
exe: ""
- platform: windows-amd64
runner: windows-latest
os: windows
arch: amd64
ext: zip
exe: ".exe"
runs-on: ${{ matrix.runner }}
defaults:
run:
shell: bash
env:
CC: ${{ matrix.os == 'windows' && 'gcc' || 'cc' }}
TAG: ${{ github.ref_name }}
steps:
- uses: actions/checkout@v4
- name: Verify tag matches src/mino.h
run: |
src_ver="v$(awk '
/^#define MINO_VERSION_MAJOR/ {maj=$3}
/^#define MINO_VERSION_MINOR/ {min=$3}
/^#define MINO_VERSION_PATCH/ {pat=$3}
END {print maj"."min"."pat}
' src/mino.h)"
tag_base="${TAG%%-*}"
if [ "$src_ver" != "$tag_base" ]; then
echo "Tag $TAG (base $tag_base) does not match src/mino.h version $src_ver" >&2
exit 1
fi
echo "Tag $TAG matches source version $src_ver"
- name: Bootstrap mino
# The Makefile detects Windows via $(OS) and produces mino.exe
# there, mino elsewhere; matches matrix.exe by construction.
run: make
- name: Smoke test
run: |
"./mino${{ matrix.exe }}" --version
out=$("./mino${{ matrix.exe }}" -e '(+ 1 2)')
if [ "$out" != "3" ]; then
echo "Smoke test failed: expected '3', got '$out'" >&2
exit 1
fi
- name: Stage release directory
run: |
dir="mino_${{ matrix.os }}_${{ matrix.arch }}_${TAG}"
mkdir -p "$dir"
cp "mino${{ matrix.exe }}" "$dir/"
cp LICENSE "$dir/"
sed \
-e "s/__VERSION__/${TAG}/g" \
-e "s/__OS__/${{ matrix.os }}/g" \
-e "s/__ARCH__/${{ matrix.arch }}/g" \
.github/release-templates/release-readme.md > "$dir/README.md"
echo "STAGE_DIR=$dir" >> "$GITHUB_ENV"
- name: Archive
run: |
if [ "${{ matrix.ext }}" = "zip" ]; then
7z a -tzip "${STAGE_DIR}.zip" "${STAGE_DIR}" >/dev/null
else
tar -czf "${STAGE_DIR}.tar.gz" "${STAGE_DIR}"
fi
ls -la "${STAGE_DIR}.${{ matrix.ext }}"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.platform }}
path: mino_${{ matrix.os }}_${{ matrix.arch }}_${{ github.ref_name }}.${{ matrix.ext }}
if-no-files-found: error
retention-days: 7
publish-draft:
name: publish draft release
needs: build
runs-on: ubuntu-22.04
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Generate checksums.txt
working-directory: dist
run: |
shasum -a 256 mino_* > checksums.txt
cat checksums.txt
- name: Create draft Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
draft: true
prerelease: ${{ contains(github.ref_name, '-') }}
fail_on_unmatched_files: true
files: |
dist/mino_*
dist/checksums.txt