-
Notifications
You must be signed in to change notification settings - Fork 31
177 lines (150 loc) · 5.9 KB
/
release.yml
File metadata and controls
177 lines (150 loc) · 5.9 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
name: Release
on:
push:
tags: ['v*']
workflow_dispatch:
inputs:
dry_run:
description: 'Dry run (skip publish)'
type: boolean
default: false
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
build-cli:
strategy:
fail-fast: false
matrix:
include:
- { target: x86_64-apple-darwin, os: macos-14 }
- { target: aarch64-apple-darwin, os: macos-14 }
- { target: x86_64-unknown-linux-gnu, os: ubuntu-latest }
- { target: aarch64-unknown-linux-gnu, os: ubuntu-latest }
- { target: x86_64-pc-windows-msvc, os: windows-latest }
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
cache-workspaces: packages/nestjs-trpc/cli -> target
- name: Install cargo-zigbuild (Linux ARM64)
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: pip3 install ziglang && cargo install cargo-zigbuild
- name: Build CLI
shell: bash
run: ./scripts/build-cli.sh --target ${{ matrix.target }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: cli-${{ matrix.target }}
path: packages/nestjs-trpc/native/
retention-days: 1
publish:
needs: build-cli
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Bun
uses: oven-sh/setup-bun@v2
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Install git-cliff
uses: taiki-e/install-action@v2
with:
tool: git-cliff
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Build TypeScript
run: bun run build
- name: Download all CLI binaries
uses: actions/download-artifact@v4
with:
path: packages/nestjs-trpc/native/
pattern: cli-*
merge-multiple: true
- name: Verify binaries
run: |
for target in x86_64-apple-darwin aarch64-apple-darwin x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu; do
test -f "packages/nestjs-trpc/native/$target/nestjs-trpc" || { echo "Missing: $target"; exit 1; }
done
test -f "packages/nestjs-trpc/native/x86_64-pc-windows-msvc/nestjs-trpc.exe" || { echo "Missing: windows"; exit 1; }
chmod +x packages/nestjs-trpc/native/x86_64-unknown-linux-gnu/nestjs-trpc
packages/nestjs-trpc/native/x86_64-unknown-linux-gnu/nestjs-trpc --help
- name: Extract version from tag
id: version
run: |
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
VERSION="${GITHUB_REF#refs/tags/v}"
else
VERSION=$(jq -r '.version' packages/nestjs-trpc/package.json)
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
- name: Update package.json version
working-directory: packages/nestjs-trpc
run: npm version ${{ steps.version.outputs.version }} --no-git-tag-version
- name: Update Cargo.toml version
run: |
sed -i 's/^version = ".*"/version = "${{ steps.version.outputs.version }}"/' packages/nestjs-trpc/cli/Cargo.toml
- name: Generate changelog
id: changelog
run: |
git-cliff --tag "v${{ steps.version.outputs.version }}" -o CHANGELOG.md
git-cliff --unreleased --tag "v${{ steps.version.outputs.version }}" > RELEASE_NOTES.md
{
echo 'changelog<<EOF'
cat RELEASE_NOTES.md
echo EOF
} >> $GITHUB_OUTPUT
- name: Publish to npm
if: ${{ github.event_name == 'push' || !inputs.dry_run }}
working-directory: packages/nestjs-trpc
run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish to npm (dry run)
if: ${{ github.event_name != 'push' && inputs.dry_run }}
working-directory: packages/nestjs-trpc
run: |
echo "DRY RUN: Would publish to npm"
npm pack
- name: Prepare release assets
run: |
mkdir -p release-assets
cp packages/nestjs-trpc/native/x86_64-apple-darwin/nestjs-trpc release-assets/nestjs-trpc-macos-x64
cp packages/nestjs-trpc/native/aarch64-apple-darwin/nestjs-trpc release-assets/nestjs-trpc-macos-arm64
cp packages/nestjs-trpc/native/x86_64-unknown-linux-gnu/nestjs-trpc release-assets/nestjs-trpc-linux-x64
cp packages/nestjs-trpc/native/aarch64-unknown-linux-gnu/nestjs-trpc release-assets/nestjs-trpc-linux-arm64
cp packages/nestjs-trpc/native/x86_64-pc-windows-msvc/nestjs-trpc.exe release-assets/nestjs-trpc-windows-x64.exe
cd release-assets && sha256sum * > checksums.txt
cat checksums.txt
- name: Create GitHub Release
if: ${{ github.event_name == 'push' || !inputs.dry_run }}
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.version.outputs.version }}
name: v${{ steps.version.outputs.version }}
body: ${{ steps.changelog.outputs.changelog }}
draft: false
prerelease: ${{ contains(steps.version.outputs.version, '-') }}
files: |
release-assets/nestjs-trpc-macos-x64
release-assets/nestjs-trpc-macos-arm64
release-assets/nestjs-trpc-linux-x64
release-assets/nestjs-trpc-linux-arm64
release-assets/nestjs-trpc-windows-x64.exe
release-assets/checksums.txt