-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (85 loc) · 2.72 KB
/
release.yml
File metadata and controls
97 lines (85 loc) · 2.72 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
name: Build and Release
on:
push:
branches: [ main, master ]
workflow_dispatch: {}
permissions:
contents: write
jobs:
build:
name: Build (${{ matrix.target }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
bin: rust_collatz_solution
archive: rust_collatz_solution-x86_64-linux-gnu.tar.gz
- os: windows-latest
target: x86_64-pc-windows-msvc
bin: rust_collatz_solution.exe
archive: rust_collatz_solution-windows-x86_64.zip
- os: windows-latest
target: i686-pc-windows-msvc
bin: rust_collatz_solution.exe
archive: rust_collatz_solution-windows-i686.zip
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust (${{ matrix.target }})
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Build
run: cargo build --release --target ${{ matrix.target }}
- name: Package (Linux)
if: runner.os == 'Linux'
shell: bash
run: |
set -euxo pipefail
mkdir -p package
cp target/${{ matrix.target }}/release/${{ matrix.bin }} package/
cp README.md package/ || true
tar -C package -czf ${{ matrix.archive }} .
- name: Package (Windows)
if: runner.os == 'Windows'
shell: bash
run: |
set -euxo pipefail
mkdir -p package
cp target/${{ matrix.target }}/release/${{ matrix.bin }} package/
cp README.md package/ || true
7z a -tzip ${{ matrix.archive }} package/*
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.archive }}
path: ${{ matrix.archive }}
release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: [ build ]
steps:
- name: Compute tag variables
id: vars
shell: bash
run: |
short_sha=${GITHUB_SHA::7}
echo "short_sha=$short_sha" >> "$GITHUB_OUTPUT"
echo "tag=build-${short_sha}-${GITHUB_RUN_NUMBER}.${GITHUB_RUN_ATTEMPT}" >> "$GITHUB_OUTPUT"
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist
- name: Create GitHub Release and upload assets
uses: softprops/action-gh-release@v2
with:
name: ${{ steps.vars.outputs.tag }}
tag_name: ${{ steps.vars.outputs.tag }}
draft: false
prerelease: false
files: dist/**/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}