-
Notifications
You must be signed in to change notification settings - Fork 1
187 lines (161 loc) · 6 KB
/
release.yml
File metadata and controls
187 lines (161 loc) · 6 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
name: Release
on:
push:
tags:
- 'v*'
env:
CARGO_TERM_COLOR: always
jobs:
docs:
name: Generate Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-docs-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-docs-
- name: Build
run: cargo build --release --locked
- name: Generate stdlib documentation
run: ./target/release/ntnt docs --generate
- name: Validate documentation
run: ./target/release/ntnt docs --validate
- name: Upload documentation artifact
uses: actions/upload-artifact@v4
with:
name: documentation
path: docs/STDLIB_REFERENCE.md
if-no-files-found: error
build:
name: Build ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false # Don't cancel other builds if one fails
matrix:
include:
- os: macos-latest
target: aarch64-apple-darwin
name: macos-arm64
archive: tar.gz
binary: ntnt
- os: ubuntu-22.04 # Use 22.04 for better glibc compatibility
target: x86_64-unknown-linux-gnu
name: linux-x64
archive: tar.gz
binary: ntnt
- os: windows-2022 # Use 2022 for stability
target: x86_64-pc-windows-msvc
name: windows-x64
archive: zip
binary: ntnt.exe
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-${{ matrix.target }}-release-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-${{ matrix.target }}-release-
- name: Build release
run: cargo build --release --locked --target ${{ matrix.target }}
- name: Verify binary exists
shell: bash
run: |
ls -la target/${{ matrix.target }}/release/
test -f target/${{ matrix.target }}/release/${{ matrix.binary }}
- name: Run unit tests (skip integration tests that spawn servers)
run: cargo test --release --locked --target ${{ matrix.target }} --lib
- name: Package (Unix)
if: matrix.archive == 'tar.gz'
shell: bash
run: |
cd target/${{ matrix.target }}/release
tar -czvf ../../../ntnt-${{ matrix.name }}.tar.gz ${{ matrix.binary }}
cd ../../..
ls -la ntnt-${{ matrix.name }}.tar.gz
- name: Package (Windows)
if: matrix.archive == 'zip'
shell: pwsh
run: |
Compress-Archive -Path target/${{ matrix.target }}/release/${{ matrix.binary }} -DestinationPath ntnt-${{ matrix.name }}.zip
Get-ChildItem ntnt-${{ matrix.name }}.zip
- name: Generate SHA256 checksum (Unix)
if: matrix.archive == 'tar.gz'
run: |
shasum -a 256 ntnt-${{ matrix.name }}.tar.gz > ntnt-${{ matrix.name }}.tar.gz.sha256
cat ntnt-${{ matrix.name }}.tar.gz.sha256
- name: Generate SHA256 checksum (Windows)
if: matrix.archive == 'zip'
shell: pwsh
run: |
$hash = (Get-FileHash -Algorithm SHA256 ntnt-${{ matrix.name }}.zip).Hash.ToLower()
"$hash ntnt-${{ matrix.name }}.zip" | Out-File -Encoding ascii ntnt-${{ matrix.name }}.zip.sha256
Get-Content ntnt-${{ matrix.name }}.zip.sha256
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ntnt-${{ matrix.name }}
path: |
ntnt-${{ matrix.name }}.${{ matrix.archive }}
ntnt-${{ matrix.name }}.${{ matrix.archive }}.sha256
if-no-files-found: error # Fail if artifact is missing
release:
name: Create Release
needs: [build, docs]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: List artifacts (debug)
run: |
echo "=== Artifact structure ==="
find artifacts -type f
echo "=== Verifying all expected files exist ==="
test -f artifacts/ntnt-macos-arm64/ntnt-macos-arm64.tar.gz
test -f artifacts/ntnt-linux-x64/ntnt-linux-x64.tar.gz
test -f artifacts/ntnt-windows-x64/ntnt-windows-x64.zip
test -f artifacts/documentation/STDLIB_REFERENCE.md
echo "All artifacts present!"
- name: Get version from tag
id: version
run: echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Create Release
uses: softprops/action-gh-release@v2
with:
name: NTNT ${{ steps.version.outputs.version }}
draft: false
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }}
generate_release_notes: true
files: |
artifacts/ntnt-macos-arm64/ntnt-macos-arm64.tar.gz
artifacts/ntnt-macos-arm64/ntnt-macos-arm64.tar.gz.sha256
artifacts/ntnt-linux-x64/ntnt-linux-x64.tar.gz
artifacts/ntnt-linux-x64/ntnt-linux-x64.tar.gz.sha256
artifacts/ntnt-windows-x64/ntnt-windows-x64.zip
artifacts/ntnt-windows-x64/ntnt-windows-x64.zip.sha256
artifacts/documentation/STDLIB_REFERENCE.md
fail_on_unmatched_files: true