Skip to content

Commit 119ee47

Browse files
committed
(cargo-release) version 0.0.13
1 parent 10a9878 commit 119ee47

File tree

5 files changed

+150
-8627
lines changed

5 files changed

+150
-8627
lines changed

.github/npm/getBinary.js

+6-10
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,20 @@ function getPlatform() {
55
const type = os.type();
66
const arch = os.arch();
77

8-
if (type === 'Windows_NT') {
9-
if (arch === 'x64') {
10-
return 'win64';
11-
} else {
12-
return 'win32';
13-
}
8+
if (type === 'Windows_NT' && arch === 'x64') {
9+
return 'windows_amd64';
1410
}
1511

1612
if (type === 'Linux' && arch === 'x64') {
17-
return 'linux';
13+
return 'linux_amd64';
1814
}
1915

2016
if (type === 'Darwin' && arch === 'x64') {
21-
return 'macos-amd64';
17+
return 'darwin_amd64';
2218
}
2319

2420
if (type === 'Darwin' && arch === 'arm64') {
25-
return 'macos-arm64';
21+
return 'darwin_arm64';
2622
}
2723

2824
throw new Error(`Unsupported platform: ${type} ${arch}. Please create an issue at https://github.com/coralogix/protofetch/issues`);
@@ -31,7 +27,7 @@ function getPlatform() {
3127
function getBinary() {
3228
const platform = getPlatform();
3329
const version = require('../package.json').version;
34-
const url = `https://github.com/coralogix/protofetch/releases/download/v${ version }/protofetch-${ platform }.tar.gz`;
30+
const url = `https://github.com/coralogix/protofetch/releases/download/v${ version }/protofetch_${ platform }.tar.gz`;
3531
return new Binary(url, { name: 'protofetch' });
3632
}
3733

.github/workflows/release.yml

+141-80
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,165 @@
1-
name: build
1+
name: release
22

33
on:
44
push:
5-
tags: ['v*.*.*']
5+
tags: [ 'v*.*.*' ]
66

77
env:
88
CARGO_TERM_COLOR: always
9-
CARGO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
9+
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
1010
NPM_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
1111

1212
jobs:
13-
release:
13+
tests:
1414
runs-on: ubuntu-latest
15-
1615
steps:
1716
- name: Checkout
1817
uses: actions/checkout@v1
19-
2018
- name: Run tests
2119
run: cargo test --verbose
2220

23-
- name: Install dependencies
24-
run: |
25-
sudo apt-get update
26-
sudo apt-get -y install gcc-mingw-w64-x86-64 gcc-mingw-w64-i686
27-
rustup target add x86_64-pc-windows-gnu
28-
rustup target add i686-pc-windows-gnu
29-
rustup target add x86_64-unknown-linux-gnu
30-
rustup target add x86_64-apple-darwin
31-
rustup target add aarch64-apple-darwin
32-
mkdir dist
33-
mkdir builds
34-
35-
36-
- name: Build Win64
37-
run: |
38-
cargo rustc --release --target=x86_64-pc-windows-gnu -- -C linker=x86_64-w64-mingw32-gcc
39-
mkdir builds/protofetch-win64
40-
cp target/x86_64-pc-windows-gnu/release/swp.exe builds/protofetch-win64
41-
tar -C builds -czvf dist/protofetch-win64.tar.gz protofetch-win64
21+
release-linux:
22+
runs-on: ubuntu-latest
23+
needs: tests
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v1
4227

43-
- name: Build Win32
44-
run: |
45-
cargo rustc --release --target=i686-pc-windows-gnu -- -C linker=i686-w64-mingw32-gcc -C link-args=-mwindows -C panic=abort
46-
mkdir builds/protofetch-win32
47-
cp target/i686-pc-windows-gnu/release/swp.exe builds/protofetch-win32
48-
tar -C builds -czvf dist/protofetch-win32.tar.gz protofetch-win32
28+
- name: Cache Rust dependencies
29+
uses: actions/[email protected]
30+
with:
31+
path: target
32+
key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }}
33+
restore-keys: |
34+
${{ runner.OS }}-build-
35+
36+
- name: Install stable toolchain linux
37+
uses: actions-rs/toolchain@v1
38+
with:
39+
profile: minimal
40+
toolchain: stable
41+
override: true
4942

50-
- name: Build Linux
43+
- name: Build for release linux
5144
run: |
52-
cargo rustc --release --target=x86_64-unknown-linux-gnu
53-
mkdir builds/protofetch_linux_amd64
54-
cp target/x86_64-unknown-linux-gnu/release/swp builds/protofetch_linux_amd64
55-
tar -C builds -czvf dist/protofetch_linux_amd64.tar.gz protofetch_linux_amd64
56-
57-
- name: Cache Mac OS dependencies
58-
id: cache-macos
59-
uses: actions/cache@v1
45+
cargo build --release
46+
tar -czvf protofetch_linux_amd64.tar.gz target/release/protofetch
47+
48+
- name: Upload release
49+
uses: softprops/action-gh-release@v1
50+
with:
51+
files: |
52+
protofetch_linux_amd64.tar.gz
53+
54+
release-mac-arm:
55+
runs-on: macos-latest
56+
needs: tests
57+
steps:
58+
- name: Checkout
59+
uses: actions/checkout@v1
60+
61+
- name: Cache Rust dependencies
62+
uses: actions/[email protected]
63+
with:
64+
path: target
65+
key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }}
66+
restore-keys: |
67+
${{ runner.OS }}-build-
68+
69+
- name: Install stable toolchain mac-arm64
70+
uses: actions-rs/toolchain@v1
6071
with:
61-
path: osxcross
62-
key: ${{ runner.os }}-osxcross
72+
profile: minimal
73+
toolchain: stable
74+
override: true
75+
target: aarch64-apple-darwin
6376

64-
- name: Install Mac OS dependencies
65-
if: steps.cache-macos.outputs.cache-hit != 'true'
77+
- name: Build for release mac-arm64
78+
# We would need self-hosted arm runner for the correct target - for now we use `vendored-openssl` feature on `git2-rs dependency to overcome it
6679
run: |
67-
git clone https://github.com/tpoechtrager/osxcross
68-
cd osxcross
69-
sudo tools/get_dependencies.sh
70-
wget -nc https://s3.dockerproject.org/darwin/v2/MacOSX10.10.sdk.tar.xz
71-
mv MacOSX10.10.sdk.tar.xz tarballs/
72-
UNATTENDED=yes OSX_VERSION_MIN=10.7 ./build.sh
73-
74-
- name: Build Mac OS amd64
80+
cargo build --release # --target=aarch64-apple-darwin
81+
tar -czvf protofetch_darwin_arm64.tar.gz target/release/protofetch
82+
83+
- name: Upload release
84+
uses: softprops/action-gh-release@v1
85+
with:
86+
files: |
87+
protofetch_darwin_arm64.tar.gz
88+
89+
release-mac-amd:
90+
runs-on: macos-latest
91+
needs: tests
92+
steps:
93+
- name: Checkout
94+
uses: actions/checkout@v1
95+
96+
- name: Cache Rust dependencies
97+
uses: actions/[email protected]
98+
with:
99+
path: target
100+
key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }}
101+
restore-keys: |
102+
${{ runner.OS }}-build-
103+
104+
- name: Install stable toolchain mac-amd64
105+
uses: actions-rs/toolchain@v1
106+
with:
107+
profile: minimal
108+
toolchain: stable
109+
override: true
110+
target: x86_64-apple-darwin
111+
112+
- name: Build for release mac-amd64
75113
run: |
76-
export PATH="$(pwd)/osxcross/target/bin:$PATH"
77-
export LIBZ_SYS_STATIC=1
78-
export CC=o64-clang
79-
export CXX=o64-clang++
80-
cargo build --release --target "x86_64-apple-darwin"
81-
mkdir builds/protofetch_darwin_amd64
82-
cp target/x86_64-apple-darwin/release/swp builds/protofetch_darwin_amd64
83-
tar -C builds -czvf dist/protofetch_darwin_amd64.tar.gz protofetch_darwin_amd64
84-
85-
- name: Build Mac OS arm64
114+
cargo build --release
115+
tar -czvf protofetch_darwin_amd64.tar.gz target/release/protofetch
116+
117+
- name: Upload release
118+
uses: softprops/action-gh-release@v1
119+
with:
120+
files: |
121+
protofetch_darwin_amd64.tar.gz
122+
123+
release-windows:
124+
runs-on: windows-latest
125+
needs: tests
126+
steps:
127+
- name: Checkout
128+
uses: actions/checkout@v1
129+
130+
- name: Cache Rust dependencies
131+
uses: actions/[email protected]
132+
with:
133+
path: target
134+
key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }}
135+
restore-keys: |
136+
${{ runner.OS }}-build-
137+
138+
- name: Install stable toolchain win64
139+
uses: actions-rs/toolchain@v1
140+
with:
141+
profile: minimal
142+
toolchain: stable
143+
override: true
144+
target: x86_64-pc-windows-gnu
145+
146+
- name: Build for release win64
86147
run: |
87-
export PATH="$(pwd)/osxcross/target/bin:$PATH"
88-
export LIBZ_SYS_STATIC=1
89-
export CC=o64-clang
90-
export CXX=o64-clang++
91-
cargo build --release --target "aarch64-apple-darwin"
92-
mkdir builds/protofetch_darwin_arm64
93-
cp target/aarch64-apple-darwin/release/swp builds/protofetch_darwin_arm64
94-
tar -C builds -czvf dist/protofetch_darwin_arm64.tar.gz protofetch_darwin_arm64
148+
cargo build --release
149+
tar -czvf protofetch_win64.tar.gz target/release/protofetch.exe
95150
96151
- name: Upload release
97152
uses: softprops/action-gh-release@v1
98153
with:
99154
files: |
100-
dist/protofetch-win64.tar.gz
101-
dist/protofetch-win32.tar.gz
102-
dist/protofetch_linux_amd64.tar.gz
103-
dist/protofetch_darwin_amd64.tar.gz
104-
dist/protofetch_darwin_arm64.tar.gz
155+
protofetch_win64.tar.gz
156+
157+
npm-release:
158+
runs-on: ubuntu-latest
159+
needs: [ release-mac-amd, release-mac-arm, release-linux, release-windows, tests ]
160+
steps:
161+
- name: Checkout
162+
uses: actions/checkout@v1
105163

106164
- name: Publish npm package
107165
run: |
@@ -110,9 +168,12 @@ jobs:
110168
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ".npmrc"
111169
npm publish
112170
171+
crates-io:
172+
runs-on: ubuntu-latest
173+
needs: tests
174+
steps:
175+
- name: Checkout
176+
uses: actions/checkout@v1
177+
113178
- name: Publish cargo package
114-
env:
115-
CARGO_ACCESS_TOKEN: ${{ secrets.CARGO_ACCESS_TOKEN }}
116-
run: |
117-
cargo login "$CARGO_ACCESS_TOKEN"
118-
cargo publish
179+
run: cargo publish --token ${{ env.CARGO_TOKEN }}

0 commit comments

Comments
 (0)