-
Notifications
You must be signed in to change notification settings - Fork 0
157 lines (135 loc) · 6.75 KB
/
release-deploy.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
name: 'release deploy'
# This will trigger the action on each push to the `release` branch.
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
env:
CLI_NAME: torytis
jobs:
build:
permissions:
contents: write
strategy:
fail-fast: false
matrix:
platform: [macos-latest, ubuntu-20.04, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
- name: setup node
uses: actions/setup-node@v4
with:
node-version: 20
- name: install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: cargo build (macos only)
if: matrix.platform == 'macos-latest'
run: |
rustup target add aarch64-apple-darwin
rustup target add x86_64-apple-darwin
cargo build --release --target aarch64-apple-darwin
cargo build --release --target x86_64-apple-darwin
mkdir -p builds/${{ env.CLI_NAME }}-aarch64-apple-darwin
cp target/aarch64-apple-darwin/release/${{ env.CLI_NAME }} builds/${{ env.CLI_NAME }}-aarch64-apple-darwin/${{ env.CLI_NAME }}
tar -C builds -czvf ${{ env.CLI_NAME }}-aarch64-apple-darwin.tar.gz ${{ env.CLI_NAME }}-aarch64-apple-darwin
mkdir -p builds/${{ env.CLI_NAME }}-x86_64-apple-darwin
cp target/x86_64-apple-darwin/release/${{ env.CLI_NAME }} builds/${{ env.CLI_NAME }}-x86_64-apple-darwin/${{ env.CLI_NAME }}
tar -C builds -czvf ${{ env.CLI_NAME }}-x86_64-apple-darwin.tar.gz ${{ env.CLI_NAME }}-x86_64-apple-darwin
- name: asset upload - aarch64 (macos only)
if: matrix.platform == 'macos-latest'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ env.CLI_NAME }}-aarch64-apple-darwin.tar.gz
asset_name: ${{ env.CLI_NAME }}-aarch64-apple-darwin.tar.gz
tag: ${{ github.ref }}
- name: asset upload - x86_64 (macos only)
if: matrix.platform == 'macos-latest'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ env.CLI_NAME }}-x86_64-apple-darwin.tar.gz
asset_name: ${{ env.CLI_NAME }}-x86_64-apple-darwin.tar.gz
tag: ${{ github.ref }}
- name: cargo build (ubuntu only)
if: matrix.platform == 'ubuntu-20.04'
run: |
sudo apt-get update -y
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update -y
sudo systemctl start docker
cargo install cross --git https://github.com/cross-rs/cross
rustup target add aarch64-unknown-linux-gnu
rustup target add x86_64-unknown-linux-gnu
cross build --release --target aarch64-unknown-linux-gnu
cross build --release --target x86_64-unknown-linux-gnu
mkdir -p builds/${{ env.CLI_NAME }}-aarch64-linux-gnu
cp target/aarch64-unknown-linux-gnu/release/${{ env.CLI_NAME }} builds/${{ env.CLI_NAME }}-aarch64-linux-gnu/${{ env.CLI_NAME }}
tar -C builds -czvf ${{ env.CLI_NAME }}-aarch64-linux-gnu.tar.gz ${{ env.CLI_NAME }}-aarch64-linux-gnu
mkdir -p builds/${{ env.CLI_NAME }}-x86_64-linux-gnu
cp target/x86_64-unknown-linux-gnu/release/${{ env.CLI_NAME }} builds/${{ env.CLI_NAME }}-x86_64-linux-gnu/${{ env.CLI_NAME }}
tar -C builds -czvf ${{ env.CLI_NAME }}-x86_64-linux-gnu.tar.gz ${{ env.CLI_NAME }}-x86_64-linux-gnu
- name: asset upload - aarch64 (ubuntu only)
if: matrix.platform == 'ubuntu-20.04'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ env.CLI_NAME }}-aarch64-linux-gnu.tar.gz
asset_name: ${{ env.CLI_NAME }}-aarch64-linux-gnu.tar.gz
tag: ${{ github.ref }}
- name: asset upload - x86_64 (ubuntu only)
if: matrix.platform == 'ubuntu-20.04'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ env.CLI_NAME }}-x86_64-linux-gnu.tar.gz
asset_name: ${{ env.CLI_NAME }}-x86_64-linux-gnu.tar.gz
tag: ${{ github.ref }}
- name: cargo build (windows only)
if: matrix.platform == 'windows-latest'
run: |
rustup target add aarch64-pc-windows-msvc
rustup target add x86_64-pc-windows-msvc
cargo build --release --target aarch64-pc-windows-msvc
cargo build --release --target x86_64-pc-windows-msvc
mkdir -p builds/${{ env.CLI_NAME }}-aarch64-pc-windows-msvc
cp target/aarch64-pc-windows-msvc/release/${{ env.CLI_NAME }}.exe builds/${{ env.CLI_NAME }}-aarch64-pc-windows-msvc/${{ env.CLI_NAME }}.exe
tar -C builds -czvf ${{ env.CLI_NAME }}-aarch64-pc-windows-msvc.tar.gz ${{ env.CLI_NAME }}-aarch64-pc-windows-msvc
mkdir -p builds/${{ env.CLI_NAME }}-x86_64-pc-windows-msvc
cp target/x86_64-pc-windows-msvc/release/${{ env.CLI_NAME }}.exe builds/${{ env.CLI_NAME }}-x86_64-pc-windows-msvc/${{ env.CLI_NAME }}.exe
tar -C builds -czvf ${{ env.CLI_NAME }}-x86_64-pc-windows-msvc.tar.gz ${{ env.CLI_NAME }}-x86_64-pc-windows-msvc
- name: asset upload - aarch64 (windows only)
if: matrix.platform == 'windows-latest'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ env.CLI_NAME }}-aarch64-pc-windows-msvc.tar.gz
asset_name: ${{ env.CLI_NAME }}-aarch64-pc-windows-msvc.tar.gz
tag: ${{ github.ref }}
- name: asset upload - x86_64 (windows only)
if: matrix.platform == 'windows-latest'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ env.CLI_NAME }}-x86_64-pc-windows-msvc.tar.gz
asset_name: ${{ env.CLI_NAME }}-x86_64-pc-windows-msvc.tar.gz
tag: ${{ github.ref }}
npm-publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 18
registry-url: https://registry.npmjs.org/
- run: |
npm publish --access=public
env:
NODE_AUTH_TOKEN: ${{ secrets.PACKAGE_PUBLISH_KEY_NPM }}
needs: build