-
Notifications
You must be signed in to change notification settings - Fork 0
114 lines (89 loc) · 2.84 KB
/
git-release.yml
File metadata and controls
114 lines (89 loc) · 2.84 KB
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
103
104
105
106
107
108
109
110
111
112
113
114
name: Bump version & release
on:
workflow_dispatch:
inputs:
version:
description: 'Semver type of new version (major / minor / patch)'
required: true
type: choice
options:
- patch
- minor
- major
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Check out source
uses: actions/checkout@v3
with:
token: ${{ secrets.PUBLISH_TOKEN }}
- name: Cache Cargo target directory
uses: actions/cache@v3
with:
path: target
key: ${{ runner.os }}-cargo-target-debug-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-target-debug-
- name: Checkout source
uses: actions/checkout@v3
- name: Check Rust formatting
run: cargo fmt --all --check
- name: Run clippy
run: cargo clippy -- -D warnings
- name: tests
run: cargo test
bump-version:
runs-on: ubuntu-latest
needs: check
outputs:
tag: ${{ steps.tags.outputs.tag }}
steps:
- name: Check out source
uses: actions/checkout@v3
with:
token: ${{ secrets.PUBLISH_TOKEN }}
- name: Cache Cargo target directory
uses: actions/cache@v3
with:
path: ~/.cargo/bin
key: cargo-bin-${{ runner.os }}
- name: Install cargo-edit util
run: |
if [ ! -f ~/.cargo/bin/cargo-set-version ]; then
cargo install cargo-edit
fi
- name: Setup Git
run: |
git config user.name 'nerjs'
git config user.email 'nerjs.stap@gmail.com'
- name: bump version
run: cargo set-version --bump ${{ github.event.inputs.version }}
- name: commit changes
run: git add . && git commit -m "Bump version"
- name: Build tag
id: tags
run: |
GITVOL_TAG="v$(cargo pkgid | cut -d "#" -f2)"
echo "Current tag: $GITVOL_TAG"
echo "tag=$GITVOL_TAG" >> $GITHUB_OUTPUT
- name: Create git tag
run: git tag -a "${{ steps.tags.outputs.tag }}" -m "${{ steps.tags.outputs.tag }}"
- name: Push latest version
run: git push origin master --follow-tags
create-github-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: bump-version
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ needs.bump-version.outputs.tag }}
fetch-tags: true
- name: Create Release
run: gh release create ${{ needs.bump-version.outputs.tag }} --generate-notes
env:
GITHUB_TOKEN: ${{ secrets.PUBLISH_TOKEN }}