-
Notifications
You must be signed in to change notification settings - Fork 1
80 lines (66 loc) · 2.56 KB
/
rust.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
name: Rust
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
inputs:
version:
description: 'The version of the release'
required: false
default: 'latest'
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Install Cross Compilation Targets
run: |
rustup target add x86_64-unknown-linux-gnu
rustup target add aarch64-unknown-linux-gnu
rustup target add x86_64-apple-darwin
rustup target add aarch64-apple-darwin
rustup target add x86_64-pc-windows-gnu
rustup target add aarch64-pc-windows-msvc
cargo install cross
- name: Build Binaries
run: |
# Get version from event input, default to 'latest' if not provided
version="${{ github.event.inputs.version }}"
[ -z "$version" ] && version="latest"
# Create bin directory
mkdir -p bin
# Define architectures for cross-compilation
architectures=("x86_64-unknown-linux-musl" "aarch64-unknown-linux-musl" "x86_64-apple-darwin" "aarch64-apple-darwin" "x86_64-pc-windows-gnu" "aarch64-pc-windows-msvc")
# Build binaries for each architecture
for arch in "${architectures[@]}"; do
cross build --release --target $arch
arch_name=$(echo $arch | sed 's/[^a-zA-Z0-9]/-/g') # Sanitize the architecture name
mv target/$arch/release/journalview bin/journalview-$version-$arch_name
done
# Set the artifact name to include the version and current date
echo "ARTIFACT_NAME=journalview-${version}-$(date +'%d.%m.%Y').zip" >> $GITHUB_ENV
- name: Create a zip file with binaries
run: |
zip -r ${{ env.ARTIFACT_NAME }} bin/
- name: Create GitHub Release
uses: actions/create-release@v1
with:
tag_name: ${{ github.ref }}
release_name: "Release ${{ github.ref }}"
body: "Release of journalview version ${{ github.event.inputs.version }}"
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload release asset
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.ARTIFACT_NAME }}
asset_name: ${{ env.ARTIFACT_NAME }}
asset_content_type: application/zip