-
Notifications
You must be signed in to change notification settings - Fork 2
72 lines (60 loc) · 2.2 KB
/
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
name: Release
on:
push:
tags:
- '*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Get latest release tag
id: latesttag
run: |
CURRENT_VERSION=$(gh release list --limit 1 --json version | jq .[0].tagName | tr -d '"')
echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV
- name: Validate new version
run: |
NEW_VERSION=${GITHUB_REF#refs/tags/}
if ! [[ $NEW_VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "The new tag $NEW_VERSION is not a valid semantic version"
exit 1
fi
if [[ $(printf '%s\n' "$NEW_VERSION" "$CURRENT_VERSION" | sort -V | head -n1) != "$CURRENT_VERSION" ]]; then
echo "The new version $NEW_VERSION is not greater than the current version $CURRENT_VERSION"
exit 1
fi
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
- name: Archive sources
run: |
tar czvf release.tar.gz Sources BUILD.bazel repositories.bzl MODULE.bazel
- name: Calculate SHA256
run: |
echo "SHA256=$(shasum -a 256 release.tar.gz | cut -d ' ' -f 1)" >> $GITHUB_ENV
- name: Create Release
run: |
set -euo pipefail
git config user.name "Release Workflow"
git config user.email "[email protected]"
gh release create "${{ github.ref }}" \
--title "${{ github.ref }}" \
--target "$GITHUB_REF_NAME" \
--generate-notes \
--prerelease \
--notes "
### Bzlmod Snippet
```bzl
bazel_dep(name = "bazelpods", version = "$new_version")
```
## Workspace Snippet
```starlark
http_archive(
name = \"bazelpods\",
sha256 = \"${{ env.SHA256 }}\",
url = \"https://github.com/sergeykhliustin/BazelPods/releases/download/${{ env.NEW_VERSION }}/release.tar.gz\"
)
load(\"@bazelpods//:repositories.bzl\", \"bazelpods_dependencies\")
bazelpods_dependencies()
```" \
"release.tar.gz"