-
Notifications
You must be signed in to change notification settings - Fork 21
209 lines (178 loc) · 6.14 KB
/
release.yml
File metadata and controls
209 lines (178 loc) · 6.14 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
name: Release
on:
workflow_dispatch:
inputs:
version:
type: choice
required: true
description: 'Version number to bump'
options:
- patch
- minor
- major
push:
branches:
- main
permissions:
contents: write
issues: write
pull-requests: write
jobs:
publish-dry-run:
name: "Runs cargo publish --dry-run"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- name: Setup Cargo Binstall
uses: cargo-bins/cargo-binstall@main
- name: Install Rust Binaries
run: |
cargo binstall -y --force cargo-edit
cargo binstall -y --force leptosfmt
cargo binstall -y --force trunk
- name: Build (debug)
run: make build
- name: publish crate
run: |
cargo package --list --allow-dirty
cargo publish -p http-server --dry-run --allow-dirty
build-binaries:
name: Build binaries
if: always() && (github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && needs.publish-dry-run.result == 'success'))
strategy:
matrix:
include:
- name: linux-x64
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- name: linux-arm64
os: ubuntu-latest
target: aarch64-unknown-linux-gnu
- name: macos-x64
os: macos-latest
target: x86_64-apple-darwin
- name: macos-arm64
os: macos-latest
target: aarch64-apple-darwin
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: |
wasm32-unknown-unknown
${{ matrix.target }}
- name: Install Linker for ARM64 Linux GNU
if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Setup Cargo Binstall
uses: cargo-bins/cargo-binstall@main
- name: Install Rust Binaries
run: |
cargo binstall -y --force cargo-tag
cargo binstall -y --force leptosfmt
cargo binstall -y --force trunk
- name: Retrieve Version
run: |
cd ./src/http-server
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "CRATE_VERSION=$(cargo tag --no-tag --no-commit -p=v ${{ inputs.version }})" >> $GITHUB_ENV
else
echo "CRATE_VERSION=$(cargo tag --no-tag --no-commit -p=v prerelease pre.$(date +%Y%m%d%H%M%S))" >> $GITHUB_ENV
fi
- name: Build binary
run: make release TARGET=${{ matrix.target }}
- name: Package binary
run: |
# Create binary name with version and target
BINARY_NAME="http-server-${{ env.CRATE_VERSION }}-${{ matrix.name }}"
# Copy and rename binary
if [ "${{ matrix.os }}" == "ubuntu-latest" ] || [ "${{ matrix.os }}" == "macos-latest" ]; then
cp target/${{ matrix.target }}/release/http-server $BINARY_NAME
fi
# Create tar.gz archive
tar -czf $BINARY_NAME.tar.gz $BINARY_NAME
# Store artifact name for later use
echo "ARTIFACT_NAME=$BINARY_NAME.tar.gz" >> $GITHUB_ENV
- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_NAME }}
release:
name: Create Release
needs: build-binaries
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: |
wasm32-unknown-unknown
${{ matrix.target }}
- name: Setup Cargo Binstall
uses: cargo-bins/cargo-binstall@main
- name: Install Rust Binaries
run: |
cargo binstall -y --force cargo-tag
- name: Commit Version Bump
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
cd ./src/http-server
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "CRATE_VERSION=$(cargo tag -p=v ${{ inputs.version }})" >> $GITHUB_ENV
else
echo "CRATE_VERSION=$(cargo tag -p=v prerelease pre.$(date +%Y%m%d%H%M%S))" >> $GITHUB_ENV
fi
git push origin main --follow-tags
- name: Login to Crates.io
if: github.event_name == 'workflow_dispatch'
run: cargo login ${CRATES_IO_TOKEN}
env:
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
- name: Publish crate
if: github.event_name == 'workflow_dispatch'
run: |
cargo package --list --allow-dirty
cargo publish -p http-server --allow-dirty
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts
- name: Create Release with GitHub CLI
env:
GH_TOKEN: ${{ github.token }}
run: |
# Determine if this is a pre-release
IS_PRERELEASE=""
if [ "${{ github.event_name }}" == "push" ]; then
IS_PRERELEASE="--prerelease"
fi
# Create the release
gh release create "${{ env.CRATE_VERSION }}" \
--title "Release ${{ env.CRATE_VERSION }}" \
--generate-notes \
$IS_PRERELEASE
# Upload all binary artifacts
for artifact_dir in ./artifacts/*/; do
if [ -d "$artifact_dir" ]; then
for file in "$artifact_dir"*.tar.gz; do
if [ -f "$file" ]; then
echo "Uploading $(basename "$file")"
gh release upload "${{ env.CRATE_VERSION }}" "$file"
fi
done
fi
done