Skip to content

Commit 7e9fcfb

Browse files
committed
feat(ci): add release workflow for GitHub Actions
1 parent 381834c commit 7e9fcfb

1 file changed

Lines changed: 85 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: "The version to release"
8+
type: string
9+
10+
permissions:
11+
contents: write
12+
pull-requests: read
13+
statuses: write
14+
packages: write
15+
16+
jobs:
17+
release:
18+
name: release
19+
runs-on: "ubuntu-latest"
20+
timeout-minutes: 15
21+
steps:
22+
- uses: actions/checkout@v5
23+
with:
24+
fetch-depth: 0
25+
- uses: jdx/mise-action@v3
26+
with:
27+
experimental: true
28+
- name: check for changes since last release
29+
id: check-changes
30+
run: |
31+
LAST_TAG=$(git tag -l | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -n 1)
32+
if [ -z "$LAST_TAG" ]; then
33+
echo "No previous Validator releases found, will release"
34+
echo "has-changes=true" >> $GITHUB_OUTPUT
35+
else
36+
if [ -n "$(git diff --name-only ${LAST_TAG}..HEAD)" ]; then
37+
echo "Validator changes found since $LAST_TAG"
38+
echo "has-changes=true" >> $GITHUB_OUTPUT
39+
else
40+
echo "No Validator changes since $LAST_TAG"
41+
echo "has-changes=false" >> $GITHUB_OUTPUT
42+
fi
43+
fi
44+
- name: Get next version
45+
id: next-version
46+
if: steps.check-changes.outputs.has-changes == 'true'
47+
env:
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
run: |
50+
NEXT_VERSION=$(git cliff --config ./cliff.toml --bumped-version)
51+
echo "NEXT_VERSION=$NEXT_VERSION" >> "$GITHUB_OUTPUT"
52+
echo "Next Validator version will be: $NEXT_VERSION"
53+
- name: Update CHANGELOG.md
54+
if: steps.check-changes.outputs.has-changes == 'true'
55+
env:
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
run: git cliff --config ./cliff.toml --bump -o ./CHANGELOG.md
58+
- name: Get release notes
59+
id: release-notes
60+
if: steps.check-changes.outputs.has-changes == 'true'
61+
env:
62+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
run: |
64+
echo "RELEASE_NOTES<<EOF" >> "$GITHUB_OUTPUT"
65+
git cliff --config ./cliff.toml --latest >> "$GITHUB_OUTPUT"
66+
echo "EOF" >> "$GITHUB_OUTPUT"
67+
- name: Commit changes
68+
id: auto-commit-action
69+
uses: stefanzweifel/git-auto-commit-action@v7
70+
if: steps.check-changes.outputs.has-changes == 'true'
71+
with:
72+
commit_options: "--allow-empty"
73+
tagging_message: ${{ steps.next-version.outputs.NEXT_VERSION }}
74+
skip_dirty_check: true
75+
commit_message: "[Release] Validator ${{ steps.next-version.outputs.NEXT_VERSION }}"
76+
- name: Create GitHub Release
77+
uses: softprops/action-gh-release@v2
78+
if: steps.check-changes.outputs.has-changes == 'true'
79+
with:
80+
draft: false
81+
repository: space-code/validator
82+
name: ${{ steps.next-version.outputs.NEXT_VERSION }}
83+
tag_name: ${{ steps.next-version.outputs.NEXT_VERSION }}
84+
body: ${{ steps.release-notes.outputs.RELEASE_NOTES }}
85+
target_commitish: ${{ steps.auto-commit-action.outputs.commit_hash }}

0 commit comments

Comments
 (0)