-
-
Notifications
You must be signed in to change notification settings - Fork 2
126 lines (116 loc) · 4.01 KB
/
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
# mostly copied from https://raw.githubusercontent.com/web-infra-dev/oxc/main/.github/workflows/release_cli.yml
name: release
on:
push:
branches: ["main"]
release:
types: [created]
workflow_dispatch:
concurrency:
group: "release"
cancel-in-progress: true
permissions:
contents: read
id-token: write
jobs:
build:
strategy:
matrix:
include:
- os: windows-latest
target: x86_64-pc-windows-msvc
code-target: win32-x64
- os: windows-latest
target: aarch64-pc-windows-msvc
code-target: win32-arm64
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
code-target: linux-x64
- os: ubuntu-20.04
target: aarch64-unknown-linux-gnu
code-target: linux-arm64
- os: macos-latest
target: x86_64-apple-darwin
code-target: darwin-x64
- os: macos-latest
target: aarch64-apple-darwin
code-target: darwin-arm64
name: Package ${{ matrix.code-target }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- run: rustup target add ${{ matrix.target }}
- name: Install arm64 toolchain
if: matrix.code-target == 'linux-arm64'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Cache
uses: Swatinem/rust-cache@v2
with:
shared-key: release-${{ matrix.target }}
- name: Build Binary
# strip debug symbols from std, see https://github.com/johnthagen/min-sized-rust#remove-panic-string-formatting-with-panic_immediate_abort
run: cargo build --release --target ${{ matrix.target }} -p hdx
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
# The binary is zipped to fix permission loss https://github.com/actions/upload-artifact#permission-loss
- name: Archive Binary
if: runner.os == 'Windows'
shell: bash
run: |
BIN_NAME=hdx-${{ matrix.code-target }}
mv target/${{ matrix.target }}/release/hdx.exe $BIN_NAME.exe
7z a $BIN_NAME.zip $BIN_NAME.exe
ls *.zip
# The binary is zipped to fix permission loss https://github.com/actions/upload-artifact#permission-loss
- name: Archive Binary
if: runner.os != 'Windows'
run: |
BIN_NAME=hdx-${{ matrix.code-target }}
mv target/${{ matrix.target }}/release/hdx $BIN_NAME
tar czf $BIN_NAME.tar.gz $BIN_NAME
ls *.tar.gz
- name: Upload Binary
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: binary-${{ matrix.code-target }}
path: |
*.zip
*.tar.gz
deploy:
env:
TAG_NAME: ${{ github.event.release.tag_name || format('0.0.0-canary.{0}', github.SHA) }}
DIST_TAG: ${{ github.event.release.tag_name && 'latest' || 'canary' }}
runs-on: ubuntu-latest
needs:
- build
steps:
- run: echo "TAG_NAME=$TAG_NAME"; echo "DIST_TAG=$DIST_TAG"
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
registry-url: https://registry.npmjs.org/
node-version: 18.x
cache-dependency-path: ./website/package.json
cache: "npm"
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: binaries
- name: Unzip
uses: montudor/action-zip@v1
with:
args: unzip -qq *.zip -d packages/hdx/bin/
- name: Untar
run: ls *.gz | xargs -i tar xf {} -C packages/hdx/bin
- run: tree
- run: npm i
working-directory: ./packages/hdx
- run: npm version ${TAG_NAME} --no-git-tag-version
working-directory: ./packages/hdx
- run: npm whoami; npm pub --provenance --tag $DIST_TAG --access public
working-directory: ./packages/hdx
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}