Skip to content

Commit 0a1da8b

Browse files
committed
chore: update release action
1 parent 557194f commit 0a1da8b

File tree

1 file changed

+65
-19
lines changed

1 file changed

+65
-19
lines changed

.github/workflows/release.yaml

Lines changed: 65 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,75 @@
11
# .github/workflows/release.yml
22

3+
name: Deploy
4+
35
on:
4-
release:
5-
types: [created]
6+
push:
7+
tags:
8+
- '[0-9]+.[0-9]+.[0-9]+'
69

710
jobs:
8-
release:
9-
name: release ${{ matrix.target }}
10-
runs-on: macos-latest
11+
build-and-upload:
12+
name: Build and upload
13+
runs-on: ${{ matrix.os }}
14+
15+
env:
16+
ASSET: ''
17+
VERSION: ''
18+
1119
strategy:
12-
fail-fast: false
1320
matrix:
1421
include:
15-
# - target: x86_64-pc-windows-gnu
16-
# archive: zip
17-
- target: x86_64-unknown-linux-musl
18-
archive: tar.gz tar.xz tar.zst
19-
- target: x86_64-apple-darwin
20-
archive: zip
22+
- build: linux
23+
os: ubuntu-latest
24+
target: x86_64-unknown-linux-musl
25+
26+
- build: macos
27+
os: macos-latest
28+
target: x86_64-apple-darwin
29+
2130
steps:
22-
- uses: actions/checkout@master
23-
- name: Compile and release
24-
uses: rust-build/[email protected]
25-
env:
26-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
- name: Clone repository
32+
uses: actions/checkout@v3
33+
34+
- name: Install Rust
35+
uses: dtolnay/rust-toolchain@stable
36+
with:
37+
targets: ${{ matrix.target }}
38+
39+
- name: Get the release version from the tag
40+
shell: bash
41+
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
42+
43+
- name: Build
44+
uses: actions-rs/cargo@v1
45+
with:
46+
use-cross: true
47+
command: build
48+
args: --verbose --release --target ${{ matrix.target }}
49+
50+
- name: Build archive
51+
shell: bash
52+
run: |
53+
binary_name="dex"
54+
55+
dirname="$binary_name-${{ env.VERSION }}-${{ matrix.target }}"
56+
mkdir "$dirname"
57+
if [ "${{ matrix.os }}" = "windows-latest" ]; then
58+
mv "target/${{ matrix.target }}/release/$binary_name.exe" "$dirname"
59+
else
60+
mv "target/${{ matrix.target }}/release/$binary_name" "$dirname"
61+
fi
62+
63+
if [ "${{ matrix.os }}" = "windows-latest" ]; then
64+
7z a "$dirname.zip" "$dirname"
65+
echo "ASSET=$dirname.zip" >> $GITHUB_ENV
66+
else
67+
tar -czf "$dirname.tar.gz" "$dirname"
68+
echo "ASSET=$dirname.tar.gz" >> $GITHUB_ENV
69+
fi
70+
71+
- name: Release
72+
uses: softprops/action-gh-release@v1
2773
with:
28-
RUSTTARGET: ${{ matrix.target }}
29-
ARCHIVE_TYPES: ${{ matrix.archive }}
74+
files: |
75+
${{ env.ASSET }}

0 commit comments

Comments
 (0)