From 7e9fcfbf0f6fcfd2d29da2cca0d021862b12bd4e Mon Sep 17 00:00:00 2001 From: Nikita Vasilev Date: Thu, 20 Nov 2025 23:15:30 +0400 Subject: [PATCH] feat(ci): add release workflow for GitHub Actions --- .github/workflows/release.yml | 85 +++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..30c6468 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,85 @@ +name: release + +on: + workflow_dispatch: + inputs: + version: + description: "The version to release" + type: string + +permissions: + contents: write + pull-requests: read + statuses: write + packages: write + +jobs: + release: + name: release + runs-on: "ubuntu-latest" + timeout-minutes: 15 + steps: + - uses: actions/checkout@v5 + with: + fetch-depth: 0 + - uses: jdx/mise-action@v3 + with: + experimental: true + - name: check for changes since last release + id: check-changes + run: | + LAST_TAG=$(git tag -l | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -n 1) + if [ -z "$LAST_TAG" ]; then + echo "No previous Validator releases found, will release" + echo "has-changes=true" >> $GITHUB_OUTPUT + else + if [ -n "$(git diff --name-only ${LAST_TAG}..HEAD)" ]; then + echo "Validator changes found since $LAST_TAG" + echo "has-changes=true" >> $GITHUB_OUTPUT + else + echo "No Validator changes since $LAST_TAG" + echo "has-changes=false" >> $GITHUB_OUTPUT + fi + fi + - name: Get next version + id: next-version + if: steps.check-changes.outputs.has-changes == 'true' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + NEXT_VERSION=$(git cliff --config ./cliff.toml --bumped-version) + echo "NEXT_VERSION=$NEXT_VERSION" >> "$GITHUB_OUTPUT" + echo "Next Validator version will be: $NEXT_VERSION" + - name: Update CHANGELOG.md + if: steps.check-changes.outputs.has-changes == 'true' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: git cliff --config ./cliff.toml --bump -o ./CHANGELOG.md + - name: Get release notes + id: release-notes + if: steps.check-changes.outputs.has-changes == 'true' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + echo "RELEASE_NOTES<> "$GITHUB_OUTPUT" + git cliff --config ./cliff.toml --latest >> "$GITHUB_OUTPUT" + echo "EOF" >> "$GITHUB_OUTPUT" + - name: Commit changes + id: auto-commit-action + uses: stefanzweifel/git-auto-commit-action@v7 + if: steps.check-changes.outputs.has-changes == 'true' + with: + commit_options: "--allow-empty" + tagging_message: ${{ steps.next-version.outputs.NEXT_VERSION }} + skip_dirty_check: true + commit_message: "[Release] Validator ${{ steps.next-version.outputs.NEXT_VERSION }}" + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + if: steps.check-changes.outputs.has-changes == 'true' + with: + draft: false + repository: space-code/validator + name: ${{ steps.next-version.outputs.NEXT_VERSION }} + tag_name: ${{ steps.next-version.outputs.NEXT_VERSION }} + body: ${{ steps.release-notes.outputs.RELEASE_NOTES }} + target_commitish: ${{ steps.auto-commit-action.outputs.commit_hash }} \ No newline at end of file