-
Notifications
You must be signed in to change notification settings - Fork 0
166 lines (163 loc) · 5.84 KB
/
npm-release.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
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
name: NPM Release
on:
workflow_dispatch:
jobs:
publish-binaries:
name: Publish binaries
runs-on: ${{ matrix.OS }}
strategy:
fail-fast: false
matrix:
include:
- NAME: linux-x64-musl
OS: ubuntu-22.04
TOOLCHAIN: stable
TARGET: x86_64-unknown-linux-musl
- NAME: linux-arm64-musl
OS: ubuntu-22.04
TOOLCHAIN: stable
TARGET: aarch64-unknown-linux-musl
- NAME: linux-arm-musleabihf
OS: ubuntu-22.04
TOOLCHAIN: stable
TARGET: arm-unknown-linux-musleabihf
- NAME: win32-x64-msvc
OS: windows-2022
TOOLCHAIN: stable
TARGET: x86_64-pc-windows-msvc
- NAME: win32-arm64-msvc
OS: windows-2022
TOOLCHAIN: stable
TARGET: aarch64-pc-windows-msvc
- NAME: darwin-x64
OS: macos-14
TOOLCHAIN: stable
TARGET: x86_64-apple-darwin
- NAME: darwin-arm64
OS: macos-14
TOOLCHAIN: stable
TARGET: aarch64-apple-darwin
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Find latest tag
uses: oprypin/find-latest-tag@v1
with:
repository: gnpaone/rust-just
releases-only: true
id: latesttag
- name: Download release artifact
uses: robinraju/[email protected]
with:
tag: ${{ steps.latesttag.outputs.tag }}
fileName: just-${{ steps.latesttag.outputs.tag }}-${{ matrix.TARGET }}.*
out-file-path: './release'
- name: Extract and Copy Binary
shell: bash
run: |
mkdir -p ./target/${{ matrix.TARGET }}/release
if [[ ${{ matrix.OS }} == 'windows-2022' ]]; then
unzip ./release/just-${{ steps.latesttag.outputs.tag }}-${{ matrix.TARGET }}.zip -d ./target/${{ matrix.TARGET }}/release/
else
tar -xzf ./release/just-${{ steps.latesttag.outputs.tag }}-${{ matrix.TARGET }}.tar.gz -C ./target/${{ matrix.TARGET }}/release/
fi
- name: Install node
uses: actions/setup-node@v4
with:
node-version: 18
registry-url: "https://registry.npmjs.org"
- name: Publish to NPM
shell: bash
run: |
cd npm
bin="just"
node_os=$(echo "${{ matrix.NAME }}" | cut -d '-' -f1)
export node_os
node_arch=$(echo "${{ matrix.NAME }}" | cut -d '-' -f2)
export node_arch
export version="${{ steps.latesttag.outputs.tag }}"
if [ "${{ matrix.OS }}" = "windows-2022" ]; then
export node_pkg="rust-${bin}-windows-${node_arch}"
else
export node_pkg="rust-${bin}-${node_os}-${node_arch}"
fi
mkdir -p "${node_pkg}/bin"
envsubst < package.json.tmpl > "${node_pkg}/package.json"
if [ "${{ matrix.OS }}" = "windows-2022" ]; then
bin="${bin}.exe"
fi
cp "../target/${{ matrix.TARGET }}/release/${bin}" "${node_pkg}/bin"
cp ../README.md "${node_pkg}"
cd "${node_pkg}"
npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
publish-npm:
name: Publish the base package to NPM
needs: publish-binaries
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Find latest tag
uses: oprypin/find-latest-tag@v1
with:
repository: gnpaone/rust-just
releases-only: true
id: latesttag
- name: Install node
uses: actions/setup-node@v4
with:
node-version: 18
registry-url: "https://registry.npmjs.org"
- name: Update version & lockfile
shell: bash
working-directory: npm/rust-just
run: |
LATEST_VERSION=$(git tag | sort -V | tail -1)
sed -i "s/\"version\": \"[0-9]\+\.[0-9]\+\.[0-9]\+\"/\"version\": \"$LATEST_VERSION\"/; s/\"\(rust-just-[^\"]*\)\": \"[0-9]\+\.[0-9]\+\.[0-9]\+\"/\"\1\": \"$LATEST_VERSION\"/g" package.json
yarn install
- name: Create PR
id: cpr
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "update version & modify lockfile"
committer: gnpaone <[email protected]>
author: gnpaone <[email protected]>
branch: npm-update
base: master
add-paths: |
npm/rust-just/package.json
npm/rust-just/yarn.lock
delete-branch: true
title: Bump npm package version
labels: ":mag_right: bump"
- name: Enable pull request automerge
if: steps.cpr.outputs.pull-request-operation == 'created'
uses: peter-evans/enable-pull-request-automerge@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
pull-request-number: ${{ steps.cpr.outputs.pull-request-number }}
- name: Delete PRs head branch
if: steps.cpr.outputs.pull-request-operation == 'created'
uses: dawidd6/action-delete-branch@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
numbers: ${{ steps.cpr.outputs.pull-request-number }}
- name: Publish the package
shell: bash
working-directory: npm/rust-just
run: |
yarn config set npmAuthToken ${NODE_AUTH_TOKEN}
yarn config set npmPublishRegistry "https://registry.npmjs.org"
yarn build
cp ../../README.md .
cp ../../CHANGELOG.md .
if [ ${{ contains(github.ref, '-') }} = "true" ]; then
yarn npm publish --tag rc
else
yarn npm publish
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}