-
Notifications
You must be signed in to change notification settings - Fork 7
300 lines (249 loc) · 9.15 KB
/
release.yml
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
name: Release
on:
push:
tags:
- "v*"
env:
MACOSX_DEPLOYMENT_TARGET: 10.7
jobs:
draft-release:
name: Create Release
runs-on: ubuntu-latest
outputs:
tag_name: ${{ steps.tag.outputs.tag_name }}
steps:
- name: Checkout the repo
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Get tag data
id: tag
run: |
# replace the following commands to use the new GITHUB_OUTPUT syntax
echo "tag_name=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
if [[ ${{ github.event.ref }} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+-[0-9]+$ ]]; then
echo "pre_release=true" >> $GITHUB_OUTPUT
fi
- name: Create new release
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
prerelease: ${{ steps.tag.outputs.pre_release == 'true' }}
title: "Version: ${{ steps.tag.outputs.tag_name }}"
draft: true
build-release:
name: Build Release Assets
needs: ["draft-release"]
runs-on: ${{ matrix.os }}
continue-on-error: true
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
platform: x86_64-Linux
flags: --all-features
- target: i686-unknown-linux-musl
os: ubuntu-latest
platform: i686-Linux
flags: --all-features
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
platform: aarch64-Linux
flags: --all-features
- target: arm-unknown-linux-musleabihf
os: ubuntu-latest
platform: arm-Linux
flags: --all-features
- target: x86_64-apple-darwin
os: macOS-latest
platform: x86_64-Darwin
flags: --all-features
- target: aarch64-apple-darwin
os: macOS-latest
platform: aarch64-Darwin
flags: --all-features
- target: x86_64-pc-windows-msvc
os: windows-latest
platform: x86_64-Windows
flags: --all-features
- target: i686-pc-windows-msvc
os: windows-latest
platform: i686-Windows
flags: --all-features
# these targets currently fail for unknown reasons
# - target: aarch64-pc-windows-msvc
# os: windows-latest
# platform: aarch64-windows
# - target: x86_64-unknown-freebsd
# os: ubuntu-latest
# platform: x86_64-FreeBSD
# flags: --all-features
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
profile: minimal
override: true
- name: Install Wix [Windows]
if: matrix.os == 'windows-latest'
uses: actions-rs/cargo@v1
with:
command: install
args: cargo-wix
- name: Cache
uses: Swatinem/rust-cache@v2
- name: Build release binary
uses: actions-rs/cargo@v1
with:
command: build
args: --release --locked ${{ matrix.flags }} --target ${{ matrix.target }} --package hop-cli
use-cross: ${{ matrix.os == 'ubuntu-latest' }}
- name: Prepare binaries [*nix]
if: matrix.os != 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
strip hop || true
tar czvf ../../../hop-${{ matrix.platform }}.tar.gz hop
cd -
- name: Prepare binaries [Windows]
if: matrix.os == 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
strip hop.exe
7z a ../../../hop-${{ matrix.platform }}.zip hop.exe
cd -
- name: Build installer [Windows]
if: matrix.os == 'windows-latest'
uses: actions-rs/cargo@v1
with:
command: wix
args: -I .\build\windows\main.wxs -v --no-build --nocapture --target ${{ matrix.target }} --output target\wix\hop-${{ matrix.platform }}.msi --package hop-cli
- name: Upload binaries
uses: actions/upload-artifact@v3
with:
name: hop-${{ matrix.platform }}.${{ matrix.os == 'windows-latest' && 'zip' || 'tar.gz' }}
path: hop-${{ matrix.platform }}.${{ matrix.os == 'windows-latest' && 'zip' || 'tar.gz' }}
- name: Upload installer [Windows]
if: matrix.os == 'windows-latest'
uses: actions/upload-artifact@v3
with:
name: hop-${{ matrix.platform }}.msi
path: target/wix/hop-${{ matrix.platform }}.msi
publish-release:
name: Publish Release
needs: ["draft-release", "build-release"]
runs-on: ubuntu-latest
continue-on-error: true
environment: prod
steps:
- name: Download Artifacts
uses: actions/download-artifact@v3
- name: Create Checksums
run: for file in hop-*/hop-*; do openssl dgst -sha256 -r "$file" | awk '{print $1}' > "${file}.sha256"; done
- name: Update Release
run: gh release edit ${{ needs.draft-release.outputs.tag_name }} --draft=false --repo=${{ github.repository }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Add Artifacts to Release
uses: softprops/action-gh-release@v1
with:
files: hop-*/hop-*
tag_name: ${{ needs.draft-release.outputs.tag_name }}
publish-crates:
name: Publish Crates
needs: ["draft-release", "build-release"]
runs-on: ubuntu-latest
continue-on-error: true
environment: prod
steps:
- name: Checkout the repo
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Login to Crates
uses: actions-rs/cargo@v1
with:
command: login
args: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Publish Crates
uses: actions-rs/cargo@v1
with:
command: publish
args: --no-verify
publish-aur:
name: Publish to AUR
needs: ["draft-release", "build-release"]
runs-on: ubuntu-latest
continue-on-error: true
environment: prod
steps:
- name: Setup SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.AUR_SSH_KEY }}" > ~/.ssh/id_ed25519
chmod 0600 ~/.ssh/id_ed25519
echo "${{ secrets.AUR_SSH_KNOWN_HOSTS }}" > ~/.ssh/known_hosts
chmod 0600 ~/.ssh/known_hosts
- name: Clone AUR repo
run: |
git config --global user.name "${{ secrets.AUR_GIT_USER }}"
git config --global user.email "${{ secrets.AUR_GIT_EMAIL }}"
git clone ssh://aur@aur.archlinux.org:/hop-cli.git --depth 1
- name: Update PKGBUILD
run: |
cd hop-cli
curl -fsSL https://github.com/${{ github.repository }}/archive/refs/tags/${{ needs.draft-release.outputs.tag_name }}.tar.gz -o hop-cli-archive.tar.gz
VERSION=$(echo ${{ needs.draft-release.outputs.tag_name }} | sed 's/v//')
OLD_VERSION=$(cat .SRCINFO | awk '/pkgver = (.*)/{ print $3 }')
sed -i "s/pkgver=.*/pkgver=$VERSION/" PKGBUILD
sed -i "s/pkgrel=.*/pkgrel=1/" PKGBUILD
sed -i "s/$OLD_VERSION/$VERSION/g" .SRCINFO
sed -i "s/pkgrel = .*/pkgrel = 1/" .SRCINFO
CHECKSUM=$(sha256sum hop-cli-archive.tar.gz | awk '{ print $1 }')
sed -i "s/sha256sums=.*/sha256sums=(\"$CHECKSUM\")/" PKGBUILD
sed -i "s/sha256sums = .*/sha256sums = $CHECKSUM/" .SRCINFO
- name: Push to AUR
run: |
cd hop-cli
git add PKGBUILD .SRCINFO
git commit -m "Update PKGBUILD for ${{ needs.draft-release.outputs.tag_name }}"
git push origin master
publish-homebrew:
name: Update Homebrew Formula
needs: ["draft-release", "build-release"]
runs-on: ubuntu-latest
continue-on-error: true
environment: prod
steps:
- name: Clone Homebrew repo
run: |
git config --global user.name "hopdeployer"
git config --global user.email "phin+hopdeployer@hop.io"
git clone https://github.com/hopinc/homebrew-tap.git --depth 1
- name: Update Formula
run: |
cd homebrew-tap
curl -fsSL https://github.com/${{ github.repository }}/archive/${{ needs.draft-release.outputs.tag_name }}.tar.gz -o hop-cli-archive.tar.gz
CHECKSUM=$(sha256sum hop-cli-archive.tar.gz | awk '{ print $1 }')
sed -i "s/\/v.*.tar.gz/\/${{ needs.draft-release.outputs.tag_name }}.tar.gz/" hop.rb
sed -i "s/sha256 .*/sha256 \"$CHECKSUM\"/" hop.rb
- name: Push to Homebrew
run: |
cd homebrew-tap
git add hop.rb
git commit -m "Update hop.rb for ${{ needs.draft-release.outputs.tag_name }}"
git push https://${{ secrets.GHCR_TOKEN }}@github.com/hopinc/homebrew-tap.git main