-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (58 loc) · 1.82 KB
/
release.yaml
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
name: Rust Build and Test
on:
push:
branches:
- '*'
jobs:
build_and_test:
runs-on: bare-metal
steps:
- uses: actions/checkout@v2
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Cargo Test
uses: actions-rs/cargo@v1
with:
command: test
- name: Build Release
uses: actions-rs/cargo@v1
with:
command: build
args: --release
- name: Install GitHub CLI
run: |
sudo apt-get update
sudo apt-get install -y gh
- name: Get the branch name
id: get-branch-name
run: echo ::set-output name=BRANCH_NAME::${GITHUB_REF#refs/heads/}
- name: Create Tag
id: create-tag
run: |
TAG="release-${GITHUB_REF#refs/heads/}"
echo "TAG=$TAG" >> $GITHUB_ENV
git tag $TAG -f
git push origin $TAG -f
- name: Create or Update Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG=$TAG
RELEASE_NAME="Release $TAG"
EXISTING_RELEASE=$(gh release view $TAG --json tagName -q .tagName || echo "")
if [[ "$EXISTING_RELEASE" == "$TAG" ]]; then
echo "Release $TAG already exists, updating..."
# gh release edit "$TAG" --title "$RELEASE_NAME" --notes "Automatically updated release."
else
echo "Creating new release $TAG..."
gh release create "$TAG" --title "$RELEASE_NAME" --notes "Automatically created release."
fi
- name: Upload Release Asset
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload $TAG ./target/release/server-stats --clobber