-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (101 loc) · 3.52 KB
/
publish.yml
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
name: publish artifacts
on:
push:
branches:
- main
workflow_dispatch:
concurrency:
group: publish-${{ github.workflow }}
permissions:
contents: write
jobs:
tests:
uses: Adjective-Object/good-fences-rs-core/.github/workflows/unittest.yml@main
publish:
needs:
- tests
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.BEACHBALL_PUSH_PAT }}
- name: pull x86_64-unknown-linux-gnu
uses: actions/download-artifact@v4
with:
name: bindings-x86_64-unknown-linux-gnu
- name: pull aarch64-unknown-linux-gnu
uses: actions/download-artifact@v4
with:
name: bindings-aarch64-unknown-linux-gnu
- name: pull x86_64-apple-darwin
uses: actions/download-artifact@v4
with:
name: bindings-x86_64-apple-darwin
- name: pull aarch64-apple-darwin
uses: actions/download-artifact@v4
with:
name: bindings-aarch64-apple-darwin
- name: pull x86_64-pc-windows-msvc
uses: actions/download-artifact@v4
with:
name: bindings-x86_64-pc-windows-msvc
- name: pull aarch64-pc-windows-msvc
uses: actions/download-artifact@v4
with:
name: bindings-aarch64-pc-windows-msvc
- name: pull js files
uses: actions/download-artifact@v4
with:
name: js-files
- name: display artifacts
run: ls -R
- name: install deps
run: yarn install
- name: copy artifacts
run: |
mkdir artifacts
cp *.node artifacts
yarn artifacts
- uses: actions/setup-node@v4
with:
node-version: "20.x"
registry-url: "https://registry.npmjs.org"
- name: Check changes
id: check_changes
run: |
git remote set-url origin https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY.git
OLD_PACKAGE_VERSION=$(node -e "console.log(require('./package.json').version)")
# Generate changes from beachball, including package.json version bump
yarn beachball bump
# check for changes
PACKAGE_VERSION=$(node -e "console.log(require('./package.json').version)")
if [ "$OLD_PACKAGE_VERSION" != "$PACKAGE_VERSION" ]; then
echo "HAS_CHANGES=true" >> "$GITHUB_OUTPUT"
else
echo "HAS_CHANGES=false" >> "$GITHUB_OUTPUT"
fi
shell: bash
- name: Publish
if: ${{ steps.check_changes.outputs.HAS_CHANGES == 'true' }}
run: |
set -exo pipefail
git config user.email "mhuan13@gmail.com"
git config user.name "$GITHUB_ACTOR"
# sync new package verson to napi-managed packages (ignored by beachball)
yarn napi version -c package.json
# Commit changes and tag with a version
PACKAGE_VERSION=$(node -e "console.log(require('./package.json').version)")
git commit -am "v$PACKAGE_VERSION"
# Push updated branch to git main branch
git tag "v$PACKAGE_VERSION"
git push origin main --tags
# dependency packages are published via "npm prepublishOnly"
# which runs the napi-rs cli under the hood.
npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.BEACHBALL_PUSH_PAT }}
GITHUB_ACTOR: autobot