-
Notifications
You must be signed in to change notification settings - Fork 2
94 lines (79 loc) · 2.42 KB
/
build-and-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
86
87
88
89
90
91
92
93
94
name: Build and Release
on:
push:
branches: [main]
tags: ['v*']
# pull_request:
# branches: [main]
permissions:
contents: write
discussions: write
pull-requests: read
env:
CARGO_TERM_COLOR: always
BINARY_NAME: stakpak
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact_name: stakpak-linux-x86_64
- os: macos-latest
target: x86_64-apple-darwin
artifact_name: stakpak-darwin-x86_64
- os: macos-latest
target: aarch64-apple-darwin
artifact_name: stakpak-darwin-aarch64
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
shared-key: ${{ matrix.target }}
- name: Build
run: cargo build --release --target ${{ matrix.target }}
- name: Run tests
run: cargo test --target ${{ matrix.target }}
- name: Prepare binary
if: startsWith(github.ref, 'refs/tags/')
run: |
cd target/${{ matrix.target }}/release
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
7z a ../../../${{ matrix.artifact_name }}.zip ${{ env.BINARY_NAME }}.exe
else
tar czf ../../../${{ matrix.artifact_name }}.tar.gz ${{ env.BINARY_NAME }}
fi
- name: Upload artifact
if: startsWith(github.ref, 'refs/tags/')
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.artifact_name }}
path: ${{ matrix.artifact_name }}.*
retention-days: 1
release:
needs: build
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: |
stakpak-linux-x86_64/stakpak-linux-x86_64.tar.gz
stakpak-darwin-x86_64/stakpak-darwin-x86_64.tar.gz
stakpak-darwin-aarch64/stakpak-darwin-aarch64.tar.gz
draft: false
prerelease: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}