-
Notifications
You must be signed in to change notification settings - Fork 0
150 lines (128 loc) · 4.06 KB
/
Copy pathrelease.yml
File metadata and controls
150 lines (128 loc) · 4.06 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
name: Release
on:
push:
tags:
- 'v*'
env:
CARGO_TERM_COLOR: always
jobs:
build:
permissions:
contents: read
strategy:
fail-fast: false
matrix:
include:
- platform: macos-latest
target: x86_64-apple-darwin
artifact: q-macos-x86_64
- platform: macos-latest
target: aarch64-apple-darwin
artifact: q-macos-aarch64
- platform: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact: q-linux-x86_64
- platform: windows-latest
target: x86_64-pc-windows-msvc
artifact: q-windows-x86_64
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
- name: Build
run: cargo build --release --locked --target ${{ matrix.target }} -p q-cli
- name: Package (unix)
if: matrix.platform != 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
tar czf ../../../${{ matrix.artifact }}.tar.gz q
cd ../../..
- name: Package (windows)
if: matrix.platform == 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
Compress-Archive -Path q.exe -DestinationPath ../../../${{ matrix.artifact }}.zip
cd ../../..
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: ${{ matrix.artifact }}.*
if-no-files-found: error
release:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
merge-multiple: true
- name: Generate checksums
run: sha256sum q-*.tar.gz q-*.zip > SHA256SUMS
- name: Extract changelog
shell: bash
run: |
version="${GITHUB_REF_NAME#v}"
awk -v heading="## [${version}]" '
$0 == heading || index($0, heading " - ") == 1 { found = 1; next }
found && /^## \[/ { exit }
found { print }
' CHANGELOG.md > RELEASE_NOTES.md
test -s RELEASE_NOTES.md
- name: Create release
uses: softprops/action-gh-release@v2
with:
draft: true
generate_release_notes: true
body_path: RELEASE_NOTES.md
files: |
q-macos-x86_64.tar.gz
q-macos-aarch64.tar.gz
q-linux-x86_64.tar.gz
q-windows-x86_64.zip
SHA256SUMS
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
npm:
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
registry-url: https://registry.npmjs.org
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
merge-multiple: true
path: artifacts
- name: Build npm packages
run: node scripts/build-npm-packages.mjs "${GITHUB_REF_NAME#v}" artifacts npm-dist
- name: Publish platform packages
run: |
for pkg in npm-dist/q-cli-*; do
name=$(node -p "require('./$pkg/package.json').name")
version=$(node -p "require('./$pkg/package.json').version")
if npm view "$name@$version" version >/dev/null 2>&1; then
echo "skipping $name@$version: already published"
continue
fi
npm publish "./$pkg" --provenance --access public
done
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish q-cli
run: npm publish ./npm-dist/q-cli --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}