-
Notifications
You must be signed in to change notification settings - Fork 0
180 lines (147 loc) · 4.4 KB
/
BINSTALL.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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
name: cargo b(inary)install
permissions: write-all
on:
push:
branches:
- main
tags-ignore:
- "**"
paths-ignore:
- "**/*.md"
- LICENSE
- "**/*.gitignore"
- .editorconfig
- docs/**
pull_request: null
jobs:
create-release:
name: Create a new github release
permissions:
contents: write
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.get-u-url.outputs.result }}
release_id: ${{ steps.get-id.outputs.result }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Create Release
id: create-release
uses: actions/github-script@v7
env:
BRANCH: ${{ github.ref_name }}
with:
script: |
const fs = require("fs");
const version = require('./package.json').version;
const { data } = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: !alpha ? version : `alpha-${alphaId}`,
name: `AHQ Store CLI v${version}`,
body: String(fs.readFileSync("./latest.md")),
draft: true,
prerelease: alpha
});
return data
- name: Get Release Id
id: get-id
uses: actions/github-script@v7
env:
data: ${{ steps.create-release.outputs.result }}
with:
result-encoding: string
script: |
let data = process.env.data;
try {
data = JSON.parse(data);
console.log(data.id);
return data.id;
} catch (_) {
console.log(data.id);
return data.id;
}
- name: Get Upload Url
id: get-u-url
uses: actions/github-script@v7
env:
data: ${{ steps.create-release.outputs.result }}
with:
result-encoding: string
script: |
let data = process.env.data;
try {
data = JSON.parse(data);
return data.upload_url;
} catch (_) {
return data.upload_url;
}
build:
needs: [create-release]
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
friendlyName: x86_64 Linux
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
friendlyName: Arm64 Linux
- os: ubuntu-latest
target: i686-unknown-linux-gnu
friendlyName: x86 Linux
- os: windows-latest
target: x86_64-pc-windows-msvc
friendlyName: x86_64 Windows
- os: windows-latest
target: i686-pc-windows-msvc
friendlyName: x86 Windows
- os: windows-latest
target: aarch64-pc-windows-msvc
friendlyName: Arm64 Windows
- os: macos-latest
target: x86_64-apple-darwin
friendlyName: x86_64 Macos
- os: macos-latest
target: aarch64-apple-darwin
friendlyName: Arm64 Macos
name: Build CLI for ${{ matrix.friendlyName }} (${{ matrix.os }}-${{ matrix.target }})
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust Nightly
run: rustup toolchain add nightly-${{ matrix.target }}
- name: Linux Cross Platform
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install zip gcc-aarch64-linux-gnu gcc-i686-linux-gnu
chmod 777 ./bundle
- name: Build CLI
run: cargo build --release
- name: Bundle CLI
run: ./bundle
env:
TARGET: ${{ matrix.target }}
publish:
needs: [create-release, build]
name: Publish Release
runs-on: ubuntu-latest
steps:
- name: Undraft Release
uses: actions/github-script@v7
env:
R_ID: ${{ needs.create-release.outputs.release_id }}
with:
script: |
github.rest.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: process.env.R_ID,
draft: false
});