Skip to content

Commit 3d768be

Browse files
author
root
committed
release-arm64
1 parent ba661c8 commit 3d768be

File tree

1 file changed

+106
-0
lines changed

1 file changed

+106
-0
lines changed

.github/workflows/release-arm64.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: Release-arm64
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
workflow_dispatch:
8+
9+
jobs:
10+
build:
11+
name: build ${{ matrix.file }} on ${{ matrix.os }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
os:
16+
- macos-latest # target: aarch64-unknown-linux-musl
17+
file:
18+
- ${{ github.event.repository.name }}
19+
runs-on: ${{ matrix.os }}
20+
defaults:
21+
run:
22+
shell: bash
23+
env:
24+
# 不同构建目标对应的 release 目录
25+
TARGET: ${{ matrix.os == 'macos-latest' && 'target/aarch64-unknown-linux-musl/release' || 'target/release' }}
26+
# 构建文件名, Windows 平台有 .exe 后缀
27+
NAME: ${{ format('{0}{1}', matrix.file, startsWith(matrix.os, 'windows') && '.exe' || '') }}
28+
# 上传制品文件名
29+
ARTIFACT_NAME: Binary-${{ matrix.file }}-${{ matrix.os }}-arm64
30+
steps:
31+
- uses: actions/checkout@master
32+
with:
33+
submodules: recursive # 递归检出git子模块(submodules)
34+
35+
- name: Cache
36+
id: cache
37+
uses: actions/cache@v3
38+
with:
39+
path: |
40+
~/.cargo
41+
~/.rustup
42+
./target
43+
key: ${{ runner.os }}-${{ matrix.file }}-arm64-cache
44+
45+
# https://github.com/FiloSottile/homebrew-musl-cross
46+
- name: musl-tools
47+
if: matrix.os == 'macos-latest'
48+
run: |
49+
brew install filosottile/musl-cross/musl-cross
50+
ln -s "$(brew --prefix musl-cross)/bin/aarch64-linux-musl-gcc" /usr/local/bin/musl-gcc
51+
which x86_64-linux-musl-gcc
52+
which aarch64-linux-musl-gcc
53+
which musl-gcc
54+
55+
- name: Rustup
56+
if: steps.cache.outputs.cache-hit != 'true' && matrix.os == 'macos-latest'
57+
run: |
58+
rustup target add aarch64-unknown-linux-musl
59+
60+
- name: Build
61+
env:
62+
CARGO_TERM_COLOR: always
63+
run: |
64+
cargo build --release --verbose \
65+
${{ matrix.os == 'macos-latest' && '--target aarch64-unknown-linux-musl' || '--' }}
66+
67+
- name: Naming ${{ env.NAMING }}
68+
id: naming
69+
env:
70+
NAMING: >-
71+
${{
72+
format('{0}-{1}-{2}-{3}{4}',
73+
matrix.file, github.ref_name, 'linux', runner.arch,
74+
startsWith(matrix.os, 'windows') && '.exe' || ''
75+
)
76+
}}
77+
run: |
78+
export NAMING="$( echo ${{ env.NAMING }} | tr [:upper:] [:lower:] )"
79+
echo "FILEPATH=$TARGET/$NAMING" >> $GITHUB_OUTPUT
80+
81+
- name: Rename file
82+
run: |
83+
mv "$TARGET/$NAME" ${{ steps.naming.outputs.FILEPATH }}
84+
85+
- name: Upload
86+
uses: actions/upload-artifact@master
87+
id: artifact-upload-step
88+
with:
89+
name: ${{ env.ARTIFACT_NAME }}
90+
path: ${{ steps.naming.outputs.FILEPATH }}
91+
92+
- name: GH Release on ${{ matrix.os }}
93+
uses: softprops/[email protected]
94+
if: startsWith(github.ref, 'refs/tags/')
95+
with:
96+
token: ${{ secrets.GITHUB_TOKEN }}
97+
files: ${{ steps.naming.outputs.FILEPATH }}
98+
99+
- name: Done
100+
if: startsWith(github.ref, 'refs/tags/')
101+
run: |
102+
echo "### [${{ github.ref_name }}](https://github.com/$GITHUB_REPOSITORY/releases/tag/${{ github.ref_name }}) Released! :rocket:" \
103+
>> $GITHUB_STEP_SUMMARY
104+
105+
permissions:
106+
contents: write

0 commit comments

Comments
 (0)