-
-
Notifications
You must be signed in to change notification settings - Fork 8
97 lines (83 loc) · 3.07 KB
/
add_release_assets.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
95
96
97
name: Finish Knope release
on:
pull_request:
types: [ closed ]
branches: [ main ]
workflow_dispatch:
jobs:
get-tag:
if: (github.head_ref == 'knope/release' && github.event.pull_request.merged == true) || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.2.2
- run: echo "tag_name=$(gh release list --json 'isDraft,tagName' --jq '.[] | select(.isDraft) | .tagName')" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ github.token }}
id: get-tag
outputs:
tag_name: ${{ steps.get-tag.outputs.tag_name }}
build-artifacts:
needs: [get-tag]
if: needs.get-tag.outputs.tag_name != ''
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
runs-on: ${{ matrix.os }}
name: ${{ matrix.target }}
steps:
- uses: actions/checkout@v4.2.2
- uses: Swatinem/rust-cache@v2
- name: Install host target
run: rustup target add ${{ matrix.target }}
- name: Install musl-tools
if: ${{ matrix.target == 'x86_64-unknown-linux-musl' }}
run: sudo apt-get install -y musl-tools
- name: Build
run: cargo build --release --target ${{ matrix.target }}
- name: Set Archive Name (Non-Windows)
id: archive
run: echo "archive_name=knope-${{ matrix.target }}" >> $GITHUB_ENV
- name: Set Archive Name (Windows)
if: ${{ matrix.os == 'windows-latest' }}
run: echo "archive_name=knope-${{ matrix.target }}" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
- name: Create Archive Folder
run: mkdir ${{ env.archive_name }}
- name: Copy Unix Artifact
if: ${{ matrix.os != 'windows-latest' }}
run: cp target/${{ matrix.target }}/release/knope ${{ env.archive_name }}
- name: Copy Windows Artifact
if: ${{ matrix.os == 'windows-latest' }}
run: cp target/${{ matrix.target }}/release/knope.exe ${{ env.archive_name }}
- name: Create Tar Archive
run: tar -czf ${{ env.archive_name }}.tgz ${{ env.archive_name }}
- name: Upload Artifact
uses: actions/upload-artifact@v4.4.3
with:
name: ${{ matrix.target }}
path: ${{ env.archive_name }}.tgz
if-no-files-found: error
release:
needs: [build-artifacts, get-tag]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.2.2
- uses: actions/download-artifact@v4.1.8
with:
path: artifacts
merge-multiple: true
- name: Upload artifacts to release
run: |
cd artifacts
gh release upload ${{ needs.get-tag.outputs.tag_name }} *
gh release edit ${{ needs.get-tag.outputs.tag_name }} --draft=false --latest
env:
GITHUB_TOKEN: ${{ secrets.PAT }}