-
Notifications
You must be signed in to change notification settings - Fork 1
56 lines (47 loc) · 1.65 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
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 version number from this push"
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 version
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