-
Notifications
You must be signed in to change notification settings - Fork 0
250 lines (219 loc) · 8.47 KB
/
release.yml
File metadata and controls
250 lines (219 loc) · 8.47 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
name: Release
permissions:
contents: write
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-*'
env:
CARGO_TERM_COLOR: always
jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Generate changelog
id: changelog
run: |
# Extract version from tag
VERSION=${GITHUB_REF#refs/tags/}
echo "VERSION=$VERSION" >> $GITHUB_ENV
# Generate basic changelog (in real implementation, use git log or conventional commits)
echo "## What's Changed" > RELEASE_NOTES.md
echo "" >> RELEASE_NOTES.md
echo "### Features" >> RELEASE_NOTES.md
echo "- Script language compiler and runtime" >> RELEASE_NOTES.md
echo "- LSP server for IDE support" >> RELEASE_NOTES.md
echo "- Package manager (manuscript)" >> RELEASE_NOTES.md
echo "" >> RELEASE_NOTES.md
echo "### Installation" >> RELEASE_NOTES.md
echo '```bash' >> RELEASE_NOTES.md
echo '# Unix/macOS' >> RELEASE_NOTES.md
echo 'curl -fsSL https://github.com/moikapy/script/releases/download/'$VERSION'/install.sh | sh' >> RELEASE_NOTES.md
echo '' >> RELEASE_NOTES.md
echo '# Windows' >> RELEASE_NOTES.md
echo 'iwr -useb https://github.com/moikapy/script/releases/download/'$VERSION'/install.ps1 | iex' >> RELEASE_NOTES.md
echo '```' >> RELEASE_NOTES.md
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Script Language ${{ env.VERSION }}
body_path: RELEASE_NOTES.md
draft: false
prerelease: ${{ contains(github.ref, '-') }}
build-release:
name: Build Release
needs: create-release
strategy:
fail-fast: false
matrix:
include:
# Linux builds
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
name: script-linux-amd64
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
name: script-linux-amd64-musl
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
name: script-linux-arm64
# macOS builds
- target: x86_64-apple-darwin
os: macos-latest
name: script-macos-amd64
- target: aarch64-apple-darwin
os: macos-latest
name: script-macos-arm64
# Windows builds
- target: x86_64-pc-windows-msvc
os: windows-latest
name: script-windows-amd64
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross-compilation tools
if: matrix.os == 'ubuntu-latest'
run: |
if [[ "${{ matrix.target }}" == "x86_64-unknown-linux-musl" ]]; then
sudo apt-get update
sudo apt-get install -y musl-tools
elif [[ "${{ matrix.target }}" == "aarch64-unknown-linux-gnu" ]]; then
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
fi
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v4
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo build
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
- name: Build release binary
run: |
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]] && [[ "${{ matrix.target }}" != "x86_64-unknown-linux-gnu" ]]; then
cargo install cross
cross build --release --target ${{ matrix.target }}
else
cargo build --release --target ${{ matrix.target }}
fi
shell: bash
- name: Build all binaries
run: |
# Build script-lsp
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]] && [[ "${{ matrix.target }}" != "x86_64-unknown-linux-gnu" ]]; then
cross build --release --target ${{ matrix.target }} --bin script-lsp
cross build --release --target ${{ matrix.target }} --bin manuscript
else
cargo build --release --target ${{ matrix.target }} --bin script-lsp
cargo build --release --target ${{ matrix.target }} --bin manuscript
fi
shell: bash
- name: Prepare release assets
run: |
# Create staging directory
mkdir -p staging
# Copy binaries
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
cp target/${{ matrix.target }}/release/script.exe staging/
cp target/${{ matrix.target }}/release/script-lsp.exe staging/
cp target/${{ matrix.target }}/release/manuscript.exe staging/
else
cp target/${{ matrix.target }}/release/script staging/
cp target/${{ matrix.target }}/release/script-lsp staging/
cp target/${{ matrix.target }}/release/manuscript staging/
chmod +x staging/*
fi
# Copy additional files
cp README.md LICENSE staging/
# Create archive
cd staging
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
7z a ../${{ matrix.name }}.zip *
cd ..
echo "ASSET=${{ matrix.name }}.zip" >> $GITHUB_ENV
else
tar czf ../${{ matrix.name }}.tar.gz *
cd ..
echo "ASSET=${{ matrix.name }}.tar.gz" >> $GITHUB_ENV
fi
shell: bash
- name: Generate checksum
run: |
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
certUtil -hashfile ${{ env.ASSET }} SHA256 > ${{ env.ASSET }}.sha256
else
shasum -a 256 ${{ env.ASSET }} > ${{ env.ASSET }}.sha256
fi
shell: bash
- name: Upload release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ${{ env.ASSET }}
asset_name: ${{ env.ASSET }}
asset_content_type: application/octet-stream
- name: Upload checksum
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ${{ env.ASSET }}.sha256
asset_name: ${{ env.ASSET }}.sha256
asset_content_type: text/plain
upload-install-scripts:
name: Upload Install Scripts
needs: [create-release, build-release]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Create install scripts
run: |
# We'll create these scripts in the next steps
mkdir -p scripts
- name: Upload Unix installer
if: hashFiles('install.sh') != ''
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ./install.sh
asset_name: install.sh
asset_content_type: text/plain
- name: Upload Windows installer
if: hashFiles('install.ps1') != ''
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ./install.ps1
asset_name: install.ps1
asset_content_type: text/plain