-
-
Notifications
You must be signed in to change notification settings - Fork 1
85 lines (74 loc) · 2.71 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: Build and Release
on:
push:
tags:
- "*"
jobs:
build:
name: Build ${{ matrix.binary_target }}
runs-on: ${{ matrix.os }}
env:
BINARY_NAME: bundlerepo
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
binary_target: x86_64-unknown-linux-musl
- os: ubuntu-latest
binary_target: x86_64-unknown-linux-gnu
- os: windows-latest
binary_target: x86_64-pc-windows-msvc
- os: macos-latest
binary_target: x86_64-apple-darwin
- os: macos-latest
binary_target: aarch64-apple-darwin
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install musl tools
if: matrix.binary_target == 'x86_64-unknown-linux-musl'
run: |
sudo apt-get update
sudo apt-get install -y musl-tools musl-dev libssl-dev pkg-config
- name: Install macOS dependencies (x86_64)
if: matrix.binary_target == 'x86_64-apple-darwin'
run: |
brew install openssl@3
echo 'export OPENSSL_DIR=$(brew --prefix openssl@3)' >> $GITHUB_ENV
- name: Install target
run: rustup target add ${{ matrix.binary_target }}
- name: Build binary
run: |
cargo build --release --target ${{ matrix.binary_target }}
- name: Set archive name
id: archive
shell: bash
run: |
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
echo "archive_name=${{ env.BINARY_NAME }}-v${{ github.ref_name }}-${{ matrix.binary_target }}.zip" >> $GITHUB_OUTPUT
else
echo "archive_name=${{ env.BINARY_NAME }}-v${{ github.ref_name }}-${{ matrix.binary_target }}.tar.gz" >> $GITHUB_OUTPUT
fi
- name: Prepare binary (Unix)
if: matrix.os != 'windows-latest'
run: |
cd target/${{ matrix.binary_target }}/release
tar -czf ../../../${{ steps.archive.outputs.archive_name }} ${{ env.BINARY_NAME }}
cd -
- name: Prepare binary (Windows)
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
cd target/${{ matrix.binary_target }}/release
$BINARY_NAME = "${{ env.BINARY_NAME }}.exe"
Compress-Archive -Path $BINARY_NAME -DestinationPath ../../../${{ steps.archive.outputs.archive_name }}
cd -
- name: Upload Release Asset
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ steps.archive.outputs.archive_name }}
asset_name: ${{ steps.archive.outputs.archive_name }}
tag: ${{ github.ref }}
overwrite: true