-
Notifications
You must be signed in to change notification settings - Fork 5
119 lines (106 loc) · 3.23 KB
/
rs-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
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
115
116
117
118
119
name: '[rs] Release (Rust)'
on:
push:
tags:
- 'rs/v*-rc'
env:
# see https://api.github.com/users/github-actions%5Bbot%5D
GITHUB_USER_NAME: github-actions[bot]
GITHUB_USER_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com
# crates in order of dependency (topological order), first the ones that are not dependent on any other
SAILS_CRATES: |
sails-idl-meta
sails-idl-parser
sails-idl-gen
sails-client-gen
sails-macros-core
sails-macros
sails-rs
sails-cli
jobs:
prepare:
name: Prepare Release
runs-on: ubuntu-latest
permissions:
contents: write
defaults:
run:
shell: bash
outputs:
rc_branch: ${{ steps.release_branch.outputs.rc_branch }}
r_version: ${{ steps.release_info.outputs.version }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Release Info
id: release_info
run: |
RELEASE_TAG=${GITHUB_REF#refs/tags/}
VERSION=${RELEASE_TAG#rs/v}
VERSION="${VERSION%-rc}"
if [[ ! $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "'$VERSION' is not a valid semver version"
exit 1
fi
echo "Version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Set Workspace Version
run: |
sed -i "s/^version = \".*\"/version = \"${{ steps.release_info.outputs.version }}\"/" Cargo.toml
- name: Update Workspace Dependencies
run: |
cargo update
- name: Create Release Branch
id: release_branch
run: |
RC_BRANCH="rc/rs/v${{ steps.release_info.outputs.version }}"
git config --global user.name "$GITHUB_USER_NAME"
git config --global user.email "$GITHUB_USER_EMAIL"
git checkout -b "$RC_BRANCH"
git add Cargo.toml
git add Cargo.lock
git commit -m "build(rs): update version to v${{ steps.release_info.outputs.version }}"
git push origin "$RC_BRANCH"
echo "rc_branch=$RC_BRANCH" >> $GITHUB_OUTPUT
ws_tests:
name: Run Workspace Tests
needs:
- prepare
uses: ./.github/workflows/rs-run-ws-tests.yml
with:
sources_ref: ${{ needs.prepare.outputs.rc_branch }}
gear_node_version: 1.6.0
cli_tests:
name: Run CLI Tests
needs:
- prepare
uses: ./.github/workflows/rs-run-cli-tests.yml
with:
sources_ref: ${{ needs.prepare.outputs.rc_branch }}
release:
name: Create Release
runs-on: ubuntu-latest
permissions:
contents: write
needs:
- prepare
- ws_tests
- cli_tests
defaults:
run:
shell: bash
steps:
- name: Checkout Code from Release Branch
uses: actions/checkout@v4
with:
ref: ${{ needs.prepare.outputs.rc_branch }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Publish Crates to Crates.io
run: |
VERSION=${{ needs.prepare.outputs.r_version }}
for SAILS_CRATE in $SAILS_CRATES; do
sed -i "/^\s*${SAILS_CRATE} = {.*}/ s/}/, version = \"=${VERSION}\" }/" Cargo.toml
done
cat Cargo.toml