Skip to content

Commit d13247f

Browse files
authored
Merge pull request #7 from nanov/feat/usage-help
f: new action
2 parents 241ee13 + 36213c5 commit d13247f

File tree

1 file changed

+43
-63
lines changed

1 file changed

+43
-63
lines changed

.github/workflows/build.yml

+43-63
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,57 @@
1-
name: Deploy
1+
name: Release
2+
3+
permissions:
4+
contents: write
25

36
on:
47
push:
58
tags:
6-
- "[0-9]+.[0-9]+.[0-9]+"
7-
8-
permissions:
9-
contents: write
9+
- v[0-9]+.*
1010

1111
jobs:
12-
build-and-upload:
13-
name: Build and upload
14-
runs-on: ${{ matrix.os }}
12+
create-release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: taiki-e/create-gh-release-action@v1
17+
with:
18+
# (optional) Path to changelog.
19+
changelog: CHANGELOG.md
20+
# (required) GitHub token for creating GitHub Releases.
21+
token: ${{ secrets.GITHUB_TOKEN }}
1522

23+
upload-assets:
24+
needs: create-release
1625
strategy:
1726
matrix:
18-
# You can add more, for any target you'd like!
1927
include:
20-
- build: linux
28+
- target: x86_64-unknown-linux-gnu
2129
os: ubuntu-latest
22-
target: x86_64-unknown-linux-musl
23-
24-
- build: macos
30+
- target: x86_64-apple-darwin
2531
os: macos-latest
26-
target: x86_64-apple-darwin
27-
32+
- target: x86_64-pc-windows-msvc
33+
os: windows-latest
34+
runs-on: ${{ matrix.os }}
2835
steps:
29-
- name: Checkout
30-
uses: actions/checkout@v3
31-
32-
- name: Get the release version from the tag
33-
shell: bash
34-
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
35-
36-
- name: Install Rust
37-
# Or @nightly if you want
38-
uses: dtolnay/[email protected]
39-
# Arguments to pass in
40-
with:
41-
# Make Rust compile to our target (defined in the matrix)
42-
targets: ${{ matrix.target }}
43-
44-
- name: Build
45-
uses: actions-rs/cargo@v1
46-
with:
47-
use-cross: true
48-
command: build
49-
args: --verbose --release --target ${{ matrix.target }}
50-
51-
- name: Build archive
52-
shell: bash
53-
run: |
54-
# Replace with the name of your binary
55-
binary_name="rae-cli"
56-
57-
dirname="$binary_name-${{ env.VERSION }}-${{ matrix.target }}"
58-
mkdir "$dirname"
59-
if [ "${{ matrix.os }}" = "windows-latest" ]; then
60-
mv "target/${{ matrix.target }}/release/$binary_name.exe" "$dirname"
61-
else
62-
mv "target/${{ matrix.target }}/release/$binary_name" "$dirname"
63-
fi
64-
65-
if [ "${{ matrix.os }}" = "windows-latest" ]; then
66-
7z a "$dirname.zip" "$dirname"
67-
echo "ASSET=$dirname.zip" >> $GITHUB_ENV
68-
else
69-
tar -czf "$dirname.tar.gz" "$dirname"
70-
echo "ASSET=$dirname.tar.gz" >> $GITHUB_ENV
71-
fi
72-
73-
- name: Release
74-
uses: softprops/action-gh-release@v1
36+
- uses: actions/checkout@v4
37+
- uses: taiki-e/upload-rust-binary-action@v1
7538
with:
76-
files: |
77-
${{ env.ASSET }}
39+
# (required) Comma-separated list of binary names (non-extension portion of filename) to build and upload.
40+
# Note that glob pattern is not supported yet.
41+
bin: ...
42+
# (optional) Target triple, default is host triple.
43+
# This is optional but it is recommended that this always be set to
44+
# clarify which target you are building for if macOS is included in
45+
# the matrix because GitHub Actions changed the default architecture
46+
# of macos-latest since macos-14.
47+
target: ${{ matrix.target }}
48+
# (optional) On which platform to distribute the `.tar.gz` file.
49+
# [default value: unix]
50+
# [possible values: all, unix, windows, none]
51+
tar: unix
52+
# (optional) On which platform to distribute the `.zip` file.
53+
# [default value: windows]
54+
# [possible values: all, unix, windows, none]
55+
zip: windows
56+
# (required) GitHub token for uploading assets to GitHub Releases.
57+
token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)