-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (71 loc) · 2.36 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
name: Release
permissions:
contents: write
on:
push:
branches:
- "main"
paths:
- "**/Cargo.toml"
env:
CARGO_TERM_COLOR: always
jobs:
release:
name: "Create New Release"
runs-on: "ubuntu-latest"
outputs:
version: ${{ steps.pkg.outputs.VERSION }}
exists: ${{ steps.check_tag.outputs.EXISTS }}
steps:
- name: "Check out the repo"
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: "Get the tag"
id: pkg
shell: "bash"
run: |
VERSION=$(awk -F ' = ' '/^\[package\]/ { in_package = 1 } /^\[/ && !/^\[package\]/ { in_package = 0 } in_package && $1 ~ /version/ { gsub(/["]/, "", $2); printf("%s",$2); exit }' Cargo.toml)
echo VERSION=$VERSION >> $GITHUB_OUTPUT
- name: Check if this is a new release
id: check_tag
shell: bash
run: |
output=$(curl -s https://api.github.com/repos/$GITHUB_REPOSITORY/git/ref/tags/${{ steps.pkg.outputs.VERSION }})
message=$(echo "$output" | awk -F': ' '/"message":/ { gsub(/"/, "", $2); print $2; }' | tr -d ',')
echo EXISTS=$([ "$message" = "Not Found" ] && echo "false" || echo "true") >> $GITHUB_OUTPUT
echo $GITHUB_OUTPUT
- name: Create a release
if: steps.check_tag.outputs.EXISTS == 'false'
uses: ncipollo/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag: v${{ steps.pkg.outputs.VERSION }}
name: v${{ steps.pkg.outputs.VERSION }}
draft: false
prerelease: false
build:
name: "Build And Upload"
if: needs.release.outputs.exists == 'false'
needs:
- release
strategy:
matrix:
include:
- target: "x86_64-unknown-linux-gnu"
os: "ubuntu-latest"
- target: "x86_64-unknown-linux-musl"
os: "ubuntu-latest"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: "Build target"
uses: "taiki-e/upload-rust-binary-action@v1"
with:
bin: "autosleep"
target: ${{ matrix.target }}
archive: $bin-${{ matrix.target }}
ref: refs/tags/v${{ needs.release.outputs.version }}
token: ${{ secrets.GITHUB_TOKEN }}
include: base,install.sh,LICENSE