-
Notifications
You must be signed in to change notification settings - Fork 2
255 lines (218 loc) · 7.69 KB
/
create-release.yml
File metadata and controls
255 lines (218 loc) · 7.69 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
name: create-release
on:
# Create a stable release
push:
tags:
- 'v*'
# Create a preview release
schedule:
- cron: '0 5 * * *'
workflow_dispatch:
env:
PREFIX: /tmp/build
jobs:
setup:
runs-on: ubuntu-latest
outputs:
is_preview: ${{ steps.set_type.outputs.is_preview }}
tmux_version: ${{ steps.meta.outputs.tmux_version }}
release_tag: ${{ steps.meta.outputs.release_tag }}
upstream_changed: ${{ steps.check_changes.outputs.upstream_changed }}
upstream_head_sha: ${{ steps.tmux_head.outputs.upstream_head_sha }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Determine build type
id: set_type
run: |
if [ "${{ github.event_name }}" = "push" ]; then
echo "Detected push event, starting stable release build."
echo "is_preview=false" >> $GITHUB_OUTPUT
else
echo "Detected scheduled or manual event, starting preview release build."
echo "is_preview=true" >> $GITHUB_OUTPUT
fi
- name: Compute metadata
id: meta
run: |
if [ "${{ steps.set_type.outputs.is_preview }}" = "true" ]; then
echo "release_tag=preview" >> $GITHUB_OUTPUT
echo "tmux_version=preview" >> $GITHUB_OUTPUT
else
VERSION="${GITHUB_REF_NAME#v}"
echo "release_tag=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT
echo "tmux_version=$VERSION" >> $GITHUB_OUTPUT
fi
- name: Get tmux upstream HEAD SHA
id: tmux_head
if: ${{ steps.set_type.outputs.is_preview == 'true' }}
run: |
git clone --depth 1 https://github.com/tmux/tmux.git
cd tmux
HEAD_SHA=$(git rev-parse --short=8 HEAD)
echo "upstream_head_sha=$HEAD_SHA" >> "$GITHUB_OUTPUT"
- name: Determine if build is needed
if: ${{ steps.set_type.outputs.is_preview == 'true' }}
id: check_changes
env:
HEAD_SHA: ${{ steps.tmux_head.outputs.upstream_head_sha }}
run: |
LAST_SHA=""
gh release download preview \
--repo ${GITHUB_REPOSITORY} \
--pattern tmux-upstream-sha.txt \
--output last-sha.txt \
>/dev/null 2>&1 || true
[ -f last-sha.txt ] && LAST_SHA="$(< last-sha.txt)"
echo "Last built SHA: $LAST_SHA"
echo "Current HEAD SHA: $HEAD_SHA"
if [ "$HEAD_SHA" = "$LAST_SHA" ]; then
echo "No changes since last preview build, skipping."
echo "upstream_changed=false" >> "$GITHUB_OUTPUT"
else
echo "New commit detected, building..."
echo "upstream_changed=true" >> "$GITHUB_OUTPUT"
fi
build:
name: Build tmux (${{ matrix.os }}-${{ matrix.arch }})
needs: setup
if: ${{ needs.setup.outputs.is_preview == 'false' || needs.setup.outputs.upstream_changed == 'true' }}
env:
TMUX_VERSION: ${{ needs.setup.outputs.tmux_version }}
strategy:
fail-fast: false
matrix:
include:
- os: linux
arch: x86_64
runs_on: ubuntu-24.04
- os: linux
arch: arm64
runs_on: ubuntu-24.04-arm
- os: macos
arch: x86_64
runs_on: macos-15-intel
- os: macos
arch: arm64
runs_on: macos-15
runs-on: ${{ matrix.runs_on }}
steps:
- name: Install build dependencies (Linux)
if: matrix.os == 'linux'
run: |
sudo apt-get update
sudo apt-get install -y \
automake \
bison \
build-essential \
git \
tar \
pkg-config \
wget
- name: Install build dependencies (macOS)
if: matrix.os == 'macos'
run: |
brew update
brew install \
automake \
bison \
git
- name: Checkout repo
uses: actions/checkout@v4
- name: Set versions
run: |
echo "Loading versions from versions.env"
source versions.env
echo "MUSL_VERSION=$MUSL_VERSION" >> "$GITHUB_ENV"
echo "LIBEVENT_VERSION=$LIBEVENT_VERSION" >> "$GITHUB_ENV"
echo "NCURSES_VERSION=$NCURSES_VERSION" >> "$GITHUB_ENV"
echo "UTF8PROC_VERSION=$UTF8PROC_VERSION" >> "$GITHUB_ENV"
- name: Build musl
if: matrix.os == 'linux'
run: |
./scripts/build_musl.sh
echo "CC=${PREFIX}/bin/musl-gcc -static" >> "$GITHUB_ENV"
- name: Build libevent
run: ./scripts/build_libevent.sh
- name: Build ncurses
run: ./scripts/build_ncurses.sh
- name: Build utf8proc
if: matrix.os == 'macos'
run: ./scripts/build_utf8proc.sh
- name: Build tmux
run: ./scripts/build_tmux.sh
- name: Verify tmux binary
run: |
./scripts/verify_tmux.sh
- name: Determine archive name
id: archive_name
run: |
if [ "${{ needs.setup.outputs.is_preview }}" = "true" ]; then
VERSION="$(date +%Y%m%d)-${{ needs.setup.outputs.upstream_head_sha }}"
else
VERSION="${GITHUB_REF_NAME#v}"
fi
echo "archive_name=tmux-${VERSION}-${{ matrix.os }}-${{ matrix.arch }}.tar.gz" >> "$GITHUB_OUTPUT"
- name: Archive tmux binary
run: |
tar -czf "${{ steps.archive_name.outputs.archive_name }}" -C ${{ env.PREFIX }}/bin tmux
- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: ${{ steps.archive_name.outputs.archive_name }}
path: ${{ steps.archive_name.outputs.archive_name }}
collect-licenses:
runs-on: ubuntu-latest
needs: setup
if: ${{ needs.setup.outputs.is_preview == 'false' || needs.setup.outputs.upstream_changed == 'true' }}
env:
TMUX_VERSION: ${{ needs.setup.outputs.tmux_version }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Collect licenses
run: |
./scripts/collect_licenses.sh
- name: Upload licenses artifact
uses: actions/upload-artifact@v4
with:
name: LICENSES.tar.gz
path: ${{ env.PREFIX }}/LICENSES.tar.gz
create-release:
needs: [setup, build, collect-licenses]
runs-on: ubuntu-latest
permissions:
contents: write
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: ${{ needs.setup.outputs.release_tag }}
TMUX_VERSION: ${{ needs.setup.outputs.tmux_version }}
IS_PREVIEW: ${{ needs.setup.outputs.is_preview }}
TMUX_SHA: ${{ needs.setup.outputs.upstream_head_sha }}
steps:
- uses: actions/download-artifact@v4
with:
merge-multiple: true
path: dist
- name: Write upstream SHA artifact
if: ${{ needs.setup.outputs.is_preview == 'true' }}
run: |
echo "${TMUX_SHA}" > dist/tmux-upstream-sha.txt
- name: Create release
run: |
if [ "$IS_PREVIEW" = "true" ]; then
TITLE="tmux preview build (${TMUX_SHA})"
NOTES="Static builds of the latest tmux from upstream master for Linux (musl) and macOS."
PRERELEASE_FLAG="--prerelease"
else
TITLE="tmux v$TMUX_VERSION"
NOTES="Static builds of tmux version $TMUX_VERSION for Linux (musl) and macOS."
PRERELEASE_FLAG=""
fi
gh release delete "$RELEASE_TAG" --repo ${GITHUB_REPOSITORY} --yes || true
gh release create "$RELEASE_TAG" \
$PRERELEASE_FLAG \
--repo ${GITHUB_REPOSITORY} \
--title "$TITLE" \
--notes "$NOTES" \
dist/*