-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (65 loc) · 2.37 KB
/
release.yaml
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
name: auto-release
on:
schedule:
- cron: '0 0 */14 * *' # Runs every 14 days at midnight UTC
workflow_dispatch:
jobs:
create-tag-release:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest]
target: [x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu]
include:
# MacOS with arm64 needs a different runner architecture
- os: macos-latest
target: aarch64-apple-darwin
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Calculate next tag
id: tag_version
run: |
new_version=$(grep '^version = ' Cargo.toml | awk '{ print $3 }' | tr -d '"')
echo "New version: $new_version"
# Check if the tag already exists
if git rev-parse "v$new_version" >/dev/null 2>&1; then
echo "Tag v$new_version already exists. Exiting."
exit 1
fi
# Set output for other steps
echo "NEW_VERSION=v$new_version" >> $GITHUB_ENV
echo "NEW_VERSION=v$new_version"
- name: Install cross
run: |
cargo install cross
- name: Install target
run: |
rustup target add ${{ matrix.target }}
- name: Cross compile
run: |
cross build --target ${{ matrix.target }} --release
# Step 6: Compress build output for each architecture
- name: Compress artifacts
run: |
mkdir -p artifacts
tar -czvf artifacts/${{ matrix.target }}-build_artifacts.tar.gz -C target/${{ matrix.target }}/release .
# Step 7: Create the new tag
- name: Create new tag
run: |
git config user.name "github-actions"
git config user.email "[email protected]"
git tag ${{ env.NEW_VERSION }}
git push origin ${{ env.NEW_VERSION }}
# Step 8: Upload the release artifacts for this architecture
- name: Create GitHub Release and Upload Artifacts
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.NEW_VERSION }}
release_name: "Release ${{ env.NEW_VERSION }}"
body: "Automated release for version ${{ env.NEW_VERSION }}"
draft: false
prerelease: false
files: artifacts/${{ matrix.target }}-build_artifacts.tar.gz