-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (61 loc) · 2.32 KB
/
release-rs.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
name: Release (Rust)
on:
push:
tags:
- 'rs/v*'
jobs:
release:
name: Release
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Release Info
id: release_info
run: |
RELEASE_TAG=${GITHUB_REF#refs/tags/}
VERSION=${RELEASE_TAG#rs/v}
if [[ ! $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "'$VERSION' is not a valid semver version"
exit 1
fi
# Fetch commit details using the GitHub API
COMMIT_DETAILS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${GITHUB_REPOSITORY}/commits/$RELEASE_TAG")
# Extract the author's name and email
AUTHOR_NAME=$(echo "$COMMIT_DETAILS" | jq -r .commit.author.name)
AUTHOR_EMAIL=$(echo "$COMMIT_DETAILS" | jq -r .commit.author.email)
echo "Author Name: $AUTHOR_NAME"
echo "Author Email: $AUTHOR_EMAIL"
echo "Version: $VERSION"
echo "author_name=$AUTHOR_NAME" >> $GITHUB_OUTPUT
echo "author_email=$AUTHOR_EMAIL" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Say Hi
run: |
echo "We are about to release: ${{ steps.release_info.outputs.version }}"
- name: Update Workspace Dependencies
run: |
cargo update
- name: Set Workspace Version
run: |
sed -i "s/^version = \".*\"/version = \"${{ steps.release_info.outputs.version }}\"/" Cargo.toml
- name: Run Tests
run: |
cargo test
- name: Commit Changes
run: |
git config --global user.name "${{ steps.release_info.outputs.author_name }}"
git config --global user.email "${{ steps.release_info.outputs.author_email }}"
git checkout -b releases/rs/v${{ steps.release_info.outputs.version }}
git add Cargo.toml
git add Cargo.lock
git commit -m "build: update version to v${{ steps.release_info.outputs.version }}"
git push origin releases/rs/v${{ steps.release_info.outputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}