Skip to content

Commit cdee5bd

Browse files
author
zer0yu
committed
fix release err
1 parent a867ed9 commit cdee5bd

File tree

1 file changed

+51
-134
lines changed

1 file changed

+51
-134
lines changed

.github/workflows/release.yml

Lines changed: 51 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -6,158 +6,75 @@ on:
66
- 'v[0-9]+.[0-9]+.[0-9]'
77
workflow_dispatch:
88

9+
permissions:
10+
contents: write
11+
912
jobs:
10-
build-nix:
11-
env:
12-
IN_PIPELINE: true
13+
build-and-upload:
14+
name: Build and upload
1315
runs-on: ${{ matrix.os }}
16+
1417
strategy:
1518
matrix:
16-
type: [ubuntu-x64, ubuntu-x86, armv7, aarch64]
19+
# You can add more, for any target you'd like!
1720
include:
18-
- type: ubuntu-x64
21+
- build: linux
1922
os: ubuntu-latest
2023
target: x86_64-unknown-linux-musl
21-
name: anew-linux
22-
path: target/x86_64-unknown-linux-musl/release/anew
23-
pkg_config_path: /usr/lib/x86_64-linux-gnu/pkgconfig
24-
- type: ubuntu-x86
25-
os: ubuntu-latest
26-
target: i686-unknown-linux-musl
27-
name: anew-linux-i386
28-
path: target/i686-unknown-linux-musl/release/anew
29-
pkg_config_path: /usr/lib/i686-linux-gnu/pkgconfig
30-
- type: armv7
31-
os: ubuntu-latest
32-
target: armv7-unknown-linux-gnueabihf
33-
name: anew-armv7
34-
path: target/armv7-unknown-linux-gnueabihf/release/anew
35-
pkg_config_path: /usr/lib/x86_64-linux-gnu/pkgconfig
36-
- type: aarch64
37-
os: ubuntu-latest
38-
target: aarch64-unknown-linux-gnu
39-
name: anew-aarch64
40-
path: target/aarch64-unknown-linux-gnu/release/anew
41-
pkg_config_path: /usr/lib/x86_64-linux-gnu/pkgconfig
42-
steps:
43-
- uses: actions/checkout@v2
44-
- name: Install System Dependencies
45-
run: |
46-
env
47-
sudo apt-get update
48-
sudo apt-get install -y --no-install-recommends libssl-dev pkg-config gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu
49-
- uses: actions-rs/toolchain@v1
50-
with:
51-
toolchain: stable
52-
target: ${{ matrix.target }}
53-
override: true
54-
- uses: actions-rs/cargo@v1
55-
env:
56-
PKG_CONFIG_PATH: ${{ matrix.pkg_config_path }}
57-
OPENSSL_DIR: /usr/lib/ssl
58-
with:
59-
use-cross: true
60-
command: build
61-
args: --release --target=${{ matrix.target }}
62-
- name: Strip symbols from binary
63-
run: |
64-
strip -s ${{ matrix.path }} || arm-linux-gnueabihf-strip -s ${{ matrix.path }} || aarch64-linux-gnu-strip -s ${{ matrix.path }}
65-
- uses: actions/upload-artifact@v2
66-
with:
67-
name: ${{ matrix.name }}
68-
path: ${{ matrix.path }}
69-
70-
build-macos:
71-
strategy:
72-
matrix:
73-
target: [x86_64-apple-darwin, aarch64-apple-darwin]
74-
include:
75-
- target: x86_64-apple-darwin
76-
arch: x86_64
77-
- target: aarch64-apple-darwin
78-
arch: arm64
79-
env:
80-
IN_PIPELINE: true
81-
runs-on: macos-latest
82-
steps:
83-
- uses: actions/checkout@v2
84-
- uses: actions-rs/toolchain@v1
85-
with:
86-
toolchain: stable
87-
target: ${{ matrix.target }}
88-
override: true
89-
- uses: actions-rs/cargo@v1
90-
with:
91-
use-cross: true
92-
command: build
93-
args: --release --target=${{ matrix.target }}
94-
- name: Strip symbols from binary
95-
run: |
96-
strip -u -r target/${{ matrix.target }}/release/anew
97-
- uses: actions/upload-artifact@v2
98-
with:
99-
name: anew-osx-${{ matrix.arch }}
100-
path: target/${{ matrix.target }}/release/anew
101-
102-
build-windows:
103-
env:
104-
IN_PIPELINE: true
105-
runs-on: ${{ matrix.os }}
106-
strategy:
107-
matrix:
108-
type: [windows-x64, windows-x86]
109-
include:
110-
- type: windows-x64
24+
- build: macos
25+
os: macos-latest
26+
target: x86_64-apple-darwin
27+
- build: windows
11128
os: windows-latest
11229
target: x86_64-pc-windows-msvc
113-
name: anew-windows.exe
114-
path: target\x86_64-pc-windows-msvc\release\anew.exe
115-
- type: windows-x86
116-
os: windows-latest
117-
target: i686-pc-windows-msvc
118-
name: anew-windows-i686.exe
119-
path: target\i686-pc-windows-msvc\release\anew.exe
30+
12031
steps:
121-
- uses: actions/checkout@v2
122-
- uses: actions-rs/toolchain@v1
32+
- name: Checkout
33+
uses: actions/checkout@v3
34+
35+
- name: Get the release version from the tag
36+
shell: bash
37+
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
38+
39+
- name: Install Rust
40+
# Or @nightly if you want
41+
uses: dtolnay/rust-toolchain@stable
42+
# Arguments to pass in
12343
with:
124-
toolchain: stable
125-
target: ${{ matrix.target }}
126-
override: true
127-
- uses: actions-rs/cargo@v1
44+
# Make Rust compile to our target (defined in the matrix)
45+
targets: ${{ matrix.target }}
46+
47+
- name: Build
48+
uses: actions-rs/cargo@v1
12849
with:
12950
use-cross: true
13051
command: build
131-
args: --release --target=${{ matrix.target }}
132-
- uses: actions/upload-artifact@v2
133-
with:
134-
name: ${{ matrix.name }}
135-
path: ${{ matrix.path }}
136-
create-release:
137-
# 确保这个任务在所有构建任务完成后执行
138-
needs: [build-nix, build-macos, build-windows]
139-
runs-on: ubuntu-latest
140-
# 这个任务只在标签推送时执行
141-
if: startsWith(github.ref, 'refs/tags/')
52+
args: --verbose --release --target ${{ matrix.target }}
14253

143-
steps:
144-
- name: Checkout code
145-
uses: actions/checkout@v2
54+
- name: Build archive
55+
shell: bash
56+
run: |
57+
# Replace with the name of your binary
58+
binary_name="anew"
14659
147-
- name: Download all artifacts
148-
uses: actions/download-artifact@v2
149-
with:
150-
path: artifacts
60+
dirname="$binary_name-${{ env.VERSION }}-${{ matrix.target }}"
61+
mkdir "$dirname"
62+
if [ "${{ matrix.os }}" = "windows-latest" ]; then
63+
mv "target/${{ matrix.target }}/release/$binary_name.exe" "$dirname"
64+
else
65+
mv "target/${{ matrix.target }}/release/$binary_name" "$dirname"
66+
fi
15167
152-
- name: List Files
153-
run: |
154-
ls artifacts
68+
if [ "${{ matrix.os }}" = "windows-latest" ]; then
69+
7z a "$dirname.zip" "$dirname"
70+
echo "ASSET=$dirname.zip" >> $GITHUB_ENV
71+
else
72+
tar -czf "$dirname.tar.gz" "$dirname"
73+
echo "ASSET=$dirname.tar.gz" >> $GITHUB_ENV
74+
fi
15575
156-
- name: Create Release
76+
- name: Release
15777
uses: softprops/action-gh-release@v1
15878
with:
15979
files: |
160-
${{ github.workspace }}/artifacts/*
161-
tag_name: ${{ github.ref == 'refs/tags/' && github.ref || 'heads/' && github.ref_name }}
162-
env:
163-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
80+
${{ env.ASSET }}

0 commit comments

Comments
 (0)