-
Notifications
You must be signed in to change notification settings - Fork 1
66 lines (56 loc) · 2.17 KB
/
tag.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
---
name: Tag a release
on:
workflow_dispatch:
inputs:
version:
description: 'Tag to apply, in the form "v0.0.0"'
required: true
jobs:
tag-release:
name: Given the tag input value, check the value, update the version number of the application, commit, tag, push tag
runs-on: ubuntu-latest
steps:
- name: Check the version number from input
run: |
echo "Validating that tag is a tag is in the correct format v0.0.1"
input_version="${{ github.event.inputs.version }}"
if grep -P '^v[0-9]+\.[0-9]+\.[0-9]+' <<< "${input_version}"; then
echo "tag=${input_version}" >> $GITHUB_ENV
echo "cargo_version=version = \"${input_version:1}\"" >> $GITHUB_ENV
elif grep -P '^[0-9]+\.[0-9]+\.[0-9]+' <<< "${input_version}"; then
echo "tag=v${input_version}" >> $GITHUB_ENV
echo "cargo_version=version = \"${input_version}\"" >> $GITHUB_ENV
else
false
fi
- name: Setup GPG
run: |
echo "${{ secrets.SIGNINGKEY }}" | gpg --import
- name: Checkout code
uses: actions/checkout@v4
- name: Setup git config
run: |
# setup the username and email.
git config user.name "Tag Bot"
git config user.email "[email protected]"
# setup gpg configuration
git config commit.gpgsign true
git config user.signingkey ${{ secrets.SIGNINGKEYHASH }}
- name: Replace the version number in the Cargo.toml files
run: |
sed -i 's/^version = .*/${{ env.cargo_version }}/g' Cargo.toml
- name: Add, push, tag, push
run: |
git add .
git commit -S -m "Release ${{ env.tag }}"
git push -f
git tag ${{ env.tag }} -s -m "Release ${{ env.tag }}"
git push origin ${{ env.tag }} -f
- name: Release Tag Repository Dispatch
uses: benc-uk/workflow-dispatch@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
repo: ${{env.GITHUB_REPOSITORY}}
ref: refs/tags/${{ env.tag }}
workflow: release.yml