-
Notifications
You must be signed in to change notification settings - Fork 2
188 lines (165 loc) · 5.9 KB
/
release.yml
File metadata and controls
188 lines (165 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
177
178
179
180
181
182
183
184
185
186
187
188
name: Release
on:
push:
branches:
- main
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
release:
name: Release
runs-on: ubuntu-latest
outputs:
published: ${{ steps.changesets.outputs.published }}
publishedPackages: ${{ steps.changesets.outputs.publishedPackages }}
env:
COREPACK_ENABLE_STRICT: 0
steps:
- uses: actions/checkout@v4
with:
filter: tree:0
fetch-depth: 0
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
run_install: false
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- name: Install Dependencies
env:
SKIP_RUST_BUILD: 1
run: pnpm install --frozen-lockfile
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
publish: pnpm ci:release
commit: "chore: version packages"
title: "chore: version packages"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Check object
run: |
cat << OBJECT
${{ toJson(steps.changesets.outputs) }}
OBJECT
release-binaries:
needs: release
if: needs.release.outputs.published == 'true'
name: Build binaries for ${{matrix.target}}
runs-on: ${{matrix.runner}}
env:
PUBLISHED_VERSION: ${{ fromJson(needs.release.outputs.publishedPackages)[0].version }}
COREPACK_ENABLE_STRICT: 0
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-unknown-linux-gnu
runner: ubuntu-latest
- target: x86_64-unknown-linux-gnu
runner: ubuntu-latest
- target: aarch64-apple-darwin
runner: macos-14
- target: x86_64-apple-darwin
runner: macos-13
- target: x86_64-pc-windows-msvc
runner: windows-latest
steps:
- name: Show published packages
run: |
echo '${{ needs.release.outputs.publishedPackages }}'
- uses: actions/checkout@v4
with:
filter: tree:0
fetch-depth: 0
- name: Install system deps (aarch64-unknown-linux-gnu)
if: ${{matrix.target == 'aarch64-unknown-linux-gnu'}}
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libc6-dev-arm64-cross
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
toolchain: 1.88.0
target: ${{matrix.target}}
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
run_install: false
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: ${{matrix.target}}
- name: Install Node.js dependencies
env:
SKIP_RUST_BUILD: 1
run: pnpm install --frozen-lockfile
- name: Build library for aarch64-unknown-linux-gnu
if: ${{matrix.target == 'aarch64-unknown-linux-gnu'}}
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
CC_aarch64_unknown_linux_gnu: aarch64-linux-gnu-gcc
CXX_aarch64_unknown_linux_gnu: aarch64-linux-gnu-g++
run: |
mkdir -p generated/${{matrix.target}}
pnpm run build:rust --target=${{matrix.target}}
cp index.node generated
- name: Build library
id: build-library
if: ${{!contains(fromJSON('["aarch64-unknown-linux-gnu"]'), matrix.target)}}
run: |
mkdir -p generated/${{matrix.target}}
pnpm run build:rust --target=${{matrix.target}}
cp index.node generated
- name: Package artifact
id: package-artifact
# This needs to be set so that this works on a Windows runner
shell: bash
env:
ARCHIVE_FILENAME: c2pa-node_${{matrix.target}}-v${{ env.PUBLISHED_VERSION || '-dev' }}.zip
run: |
cd generated
7z a -tzip "${{ env.ARCHIVE_FILENAME }}" index.node
echo "archive=${{ env.ARCHIVE_FILENAME }}" >> "$GITHUB_OUTPUT"
- name: Upload artifact (development only)
id: upload-artifact
uses: actions/upload-artifact@v4
if: needs.release.outputs.published != 'true'
with:
name: ${{ steps.package-artifact.outputs.archive }}
path: generated/${{ steps.package-artifact.outputs.archive }}
retention-days: 3
- id: get-release-id
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "id=$(curl -s -L \
-H 'Accept: application/vnd.github+json' \
-H 'Authorization: Bearer ${{ env.GITHUB_TOKEN }}' \
-H 'X-GitHub-Api-Version: 2022-11-28' \
https://api.github.com/repos/${{ github.repository }}/releases/tags/v${{ env.PUBLISHED_VERSION }} | jq '.id')" >> "$GITHUB_OUTPUT"
- name: Upload release asset
if: needs.release.outputs.published == 'true'
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ env.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Content-Type: application/zip" \
"https://uploads.github.com/repos/${{ github.repository }}/releases/${{ steps.get-release-id.outputs.id }}/assets?name=${{ steps.package-artifact.outputs.archive }}" \
--data-binary "@generated/${{ steps.package-artifact.outputs.archive }}"