-
Notifications
You must be signed in to change notification settings - Fork 1
128 lines (114 loc) · 3.95 KB
/
Copy pathrelease.yml
File metadata and controls
128 lines (114 loc) · 3.95 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: Release
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"
- "dev-v[0-9]+.[0-9]+.[0-9]+*"
jobs:
build_and_test:
name: Build and Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Build
run: cargo build --all-features --release
- name: Run tests
run: cargo test --all-features
build_release:
name: Build Release Binaries
needs: build_and_test
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
artifact_name: rustybox
asset_name: rustybox-linux-amd64
target: x86_64-unknown-linux-gnu
# - os: windows-latest
# artifact_name: rustybox.exe
# asset_name: rustybox-windows-amd64.exe
# target: x86_64-pc-windows-msvc
- os: macos-latest
artifact_name: rustybox
asset_name: rustybox-macos-amd64
target: x86_64-apple-darwin
- os: macos-latest
artifact_name: rustybox
asset_name: rustybox-macos-arm64
target: aarch64-apple-darwin
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.target }}
- name: Install cross-compilation dependencies
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Build binary
run: cargo build --release --target ${{ matrix.target }}
- name: Prepare binary
shell: bash
run: |
mkdir -p release
if [ "${{ matrix.os }}" = "windows-latest" ]; then
cp target/${{ matrix.target }}/release/${{ matrix.artifact_name }} release/${{ matrix.asset_name }}
else
cp target/${{ matrix.target }}/release/${{ matrix.artifact_name }} release/${{ matrix.asset_name }}
chmod +x release/${{ matrix.asset_name }}
fi
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset_name }}
path: release/${{ matrix.asset_name }}
if-no-files-found: error
create_release:
name: Create GitHub Release
needs: build_release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Check if development release
id: check_dev
run: |
if [[ "${{ github.ref_name }}" == dev-* ]]; then
echo "is_dev=true" >> $GITHUB_OUTPUT
else
echo "is_dev=false" >> $GITHUB_OUTPUT
fi
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
name: ${{ steps.check_dev.outputs.is_dev == 'true' && format('Development Release {0}', github.ref_name) || format('Release {0}', github.ref_name) }}
body: |
## Binary Downloads
The following binaries are available for this release:
* Linux (amd64)
* macOS (amd64)
* macOS (arm64)
${{ steps.check_dev.outputs.is_dev == 'true' && '⚠️ This is a development release from the develop branch and may contain unstable features.' || '' }}
draft: false
prerelease: ${{ steps.check_dev.outputs.is_dev }}
files: |
artifacts/rustybox-linux-amd64/rustybox-linux-amd64
artifacts/rustybox-macos-amd64/rustybox-macos-amd64
artifacts/rustybox-macos-arm64/rustybox-macos-arm64