-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (64 loc) · 2.38 KB
/
release-check.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
name: Release
on:
push:
branches:
- release/[0-9]+.[0-9]+.[0-9]
# Matches branches containing an arbitrary suffix starting with '-'.
- release/[0-9]+.[0-9]+.[0-9]+-*
tags:
- v[0-9]+.[0-9]+.[0-9]
# Matches tags containing an arbitrary suffix starting with '-'.
- v[0-9]+.[0-9]+.[0-9]+-*
env:
CARGO_TERM_COLOR: always
jobs:
release-check:
if: startsWith(github.ref, 'refs/heads/release')
name: Check for release
runs-on: ubuntu-latest
strategy:
matrix:
runtime: [ bajun ]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get crate and release versions
run: |
echo "CRATE_VERSIONS=$(cargo tree --depth=0 --workspace | egrep -o '[0-9]+\.[0-9]+\.[0-9]+' | uniq)" >> $GITHUB_ENV
echo "RELEASE_VERSION=${GITHUB_REF_NAME#release/}" >> $GITHUB_ENV
- name: Check release version is bumped
run: |
[ -z "$(git tag --list)" ] && {
echo "skipping as there are no tags yet"
exit 0
}
TAG=$(git describe --tags --abbrev=0 | tr -d v)
echo "previous release version: $TAG"
echo "current release version: ${{ env.RELEASE_VERSION }}"
[ $TAG -eq ${{ env.RELEASE_VERSION }} ] && {
echo "release version must be bumped"
exit 1
}
exit 0
- name: Check crate and release versions match
run: |
[ $(echo ${{ env.CRATE_VERSIONS }} | wc -w | xargs) -ne 1 ] && {
echo "all crate versions should be equal"
exit 1
}
[ "${{ env.CRATE_VERSIONS }}" != "${{ env.RELEASE_VERSION }}" ] && {
echo "release version (${{ env.CRATE_VERSIONS }}) is not equal to crate versions (${{ env.CRATE_VERSIONS }})"
exit 1
}
echo "crate version: ${{ env.CRATE_VERSIONS }}"
echo "release version: ${{ env.RELEASE_VERSION }}"
exit 0
- name: Check spec version match
run: |
RELEASE_VERSION=$(echo ${{ env.RELEASE_VERSION }} | tr -d .)
RELEASE_VERSION_INTEGER=$((10#$RELEASE_VERSION))
SPEC_VERSION=$(grep "spec_version" runtime/${{ matrix.runtime }}/**/lib.rs | egrep -o "[0-9]+")
echo "release version as integer: $RELEASE_VERSION_INTEGER"
echo "spec version: $SPEC_VERSION"
exit 0