-
Notifications
You must be signed in to change notification settings - Fork 2
152 lines (129 loc) · 4.46 KB
/
Copy pathrelease.yml
File metadata and controls
152 lines (129 loc) · 4.46 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
name: Release
on:
push:
tags: ['v*']
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build (${{ matrix.target }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
cross: true
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross
if: matrix.cross
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Build
run: |
if [ "${{ matrix.cross }}" = "true" ]; then
cross build --release --target ${{ matrix.target }}
else
cargo build --release --target ${{ matrix.target }}
fi
- name: Package
run: |
VERSION=${GITHUB_REF_NAME#v}
ARCHIVE="scriptr-${VERSION}-${{ matrix.target }}.tar.gz"
tar -czvf "$ARCHIVE" -C "target/${{ matrix.target }}/release" scriptr
echo "ARCHIVE=$ARCHIVE" >> $GITHUB_ENV
- name: Compute SHA256
run: |
if command -v sha256sum &>/dev/null; then
sha256sum "$ARCHIVE" > "$ARCHIVE.sha256"
else
shasum -a 256 "$ARCHIVE" > "$ARCHIVE.sha256"
fi
- uses: actions/upload-artifact@v4
with:
name: scriptr-${{ matrix.target }}
path: |
scriptr-*.tar.gz
scriptr-*.tar.gz.sha256
release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.repository.default_branch }}
- uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "$GITHUB_REF_NAME" artifacts/scriptr-*.tar.gz \
--title "$GITHUB_REF_NAME" \
--generate-notes
- name: Update formula
run: |
VERSION=${GITHUB_REF_NAME#v}
sha_for() { cut -d' ' -f1 < "artifacts/scriptr-${VERSION}-$1.tar.gz.sha256"; }
AARCH64_MACOS=$(sha_for aarch64-apple-darwin)
X86_64_MACOS=$(sha_for x86_64-apple-darwin)
X86_64_LINUX=$(sha_for x86_64-unknown-linux-gnu)
AARCH64_LINUX=$(sha_for aarch64-unknown-linux-gnu)
cat > Formula/scriptr.rb << FORMULA
class Scriptr < Formula
desc "Fast, caching launcher for Rust single-file packages"
homepage "https://github.com/tekacs/scriptr"
version "${VERSION}"
license "MIT OR Apache-2.0"
on_macos do
on_arm do
url "https://github.com/tekacs/scriptr/releases/download/v${VERSION}/scriptr-${VERSION}-aarch64-apple-darwin.tar.gz"
sha256 "${AARCH64_MACOS}"
end
on_intel do
url "https://github.com/tekacs/scriptr/releases/download/v${VERSION}/scriptr-${VERSION}-x86_64-apple-darwin.tar.gz"
sha256 "${X86_64_MACOS}"
end
end
on_linux do
on_arm do
url "https://github.com/tekacs/scriptr/releases/download/v${VERSION}/scriptr-${VERSION}-aarch64-unknown-linux-gnu.tar.gz"
sha256 "${AARCH64_LINUX}"
end
on_intel do
url "https://github.com/tekacs/scriptr/releases/download/v${VERSION}/scriptr-${VERSION}-x86_64-unknown-linux-gnu.tar.gz"
sha256 "${X86_64_LINUX}"
end
end
def install
bin.install "scriptr"
end
test do
system "#{bin}/scriptr", "--version"
end
end
FORMULA
- name: Commit formula update
run: |
VERSION=${GITHUB_REF_NAME#v}
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/scriptr.rb
git diff --staged --quiet || {
git commit -m "formula: update to v${VERSION}"
git push
}