forked from trumank/mint
-
Notifications
You must be signed in to change notification settings - Fork 1
102 lines (89 loc) · 2.57 KB
/
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
95
96
97
98
99
100
101
102
name: Cargo Release Workflow
on:
workflow_dispatch:
push:
tags:
- 'v*'
env:
CARGO_TERM_COLOR: always
jobs:
all-go:
name: all systems go
runs-on: ubuntu-latest
needs:
- test
- build
- release
steps:
- run: exit 0
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest]
architecture: [x64]
toolchain: [stable]
steps:
- uses: actions/checkout@v3
- name: Run Tests
run: cargo test --verbose
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest]
architecture: [x64]
toolchain: [stable]
steps:
- uses: actions/checkout@v3
- name: Build
run: cargo build --release --verbose
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.os }}-${{ matrix.architecture }}
path: target/release/
release:
needs:
- test
- build
runs-on: ubuntu-latest
strategy:
matrix:
os: [windows-latest]
architecture: [x64]
toolchain: [stable]
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- name: Download Artifacts
uses: actions/download-artifact@v3
- name: Set Build File Variables
id: vars
run: |
name=$(awk -F '= ' '/^\[package\]/{found=1} found && /^name/{gsub(/["]/, "", $2); print $2; exit}' Cargo.toml)
echo "name=$name" >> $GITHUB_OUTPUT
os="${{ matrix.os }}"
os_sans_latest=$(echo "$os" | sed 's/-latest//')
echo "os=$os_sans_latest" >> $GITHUB_OUTPUT
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
echo "ext=.exe" >> $GITHUB_OUTPUT
else
echo "ext=" >> $GITHUB_OUTPUT
fi
- name: Prepare Artifacts
run: |
source=${{ matrix.os }}-${{ matrix.architecture }}/${{ steps.vars.outputs.name }}${{ steps.vars.outputs.ext }}
target=bin/${{ steps.vars.outputs.name }}-${{ steps.vars.outputs.os }}-${{ matrix.architecture }}${{ steps.vars.outputs.ext }}
mkdir bin
mv $source $target
- name: Create Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
draft: false
prerelease: false
token: ${{ secrets.GITHUB_TOKEN }}
files: |
bin/${{ steps.vars.outputs.name }}-${{ steps.vars.outputs.os }}-${{ matrix.architecture }}${{ steps.vars.outputs.ext }}