release #6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| outputs: | |
| has-changes: ${{ steps.check-changes.outputs.has-changes }} | |
| next-version: ${{ steps.next-version.outputs.NEXT_VERSION }} | |
| commit-hash: ${{ steps.auto-commit-action.outputs.commit_hash }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| 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: Update README.md version | |
| if: steps.check-changes.outputs.has-changes == 'true' | |
| run: | | |
| sed -i -E 's|https://github.com/space-code/validator.git", from: "[0-9]+\.[0-9]+\.[0-9]+"|https://github.com/space-code/validator.git", from: "'"${{ steps.next-version.outputs.NEXT_VERSION }}"'"|g' README.md | |
| echo "Updated README.md with version ${{ steps.next-version.outputs.NEXT_VERSION }}" | |
| - 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<<EOF" >> "$GITHUB_OUTPUT" | |
| echo "All notable changes to this project will be documented in this file." >> "$GITHUB_OUTPUT" | |
| echo "" >> "$GITHUB_OUTPUT" | |
| echo "The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)," >> "$GITHUB_OUTPUT" | |
| echo "and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)." >> "$GITHUB_OUTPUT" | |
| echo "" >> "$GITHUB_OUTPUT" | |
| git cliff --config ./cliff.toml --tag ${{ steps.next-version.outputs.NEXT_VERSION }} --unreleased --strip header | awk 'NF{p=1} p' | tail -n +2 >> "$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 --no-verify" | |
| 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 }} | |
| docc: | |
| name: build and deploy docc | |
| runs-on: macos-latest | |
| needs: release | |
| if: ${{ needs.release.outputs.has-changes == 'true' }} | |
| timeout-minutes: 15 | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ needs.release.outputs.commit-hash }} | |
| fetch-depth: 0 | |
| - name: Build DocC | |
| id: build | |
| uses: space-code/build-docc@main | |
| with: | |
| schemes: '["ValidatorCore", "ValidatorUI"]' | |
| version: ${{ needs.release.outputs.next-version }} | |
| - name: Generate Index Page | |
| uses: space-code/generate-index@v1.0.0 | |
| with: | |
| version: ${{ needs.release.outputs.next-version }} | |
| project-name: 'Validator' | |
| project-description: 'Validator is a modern, lightweight Swift framework that provides elegant and type-safe input validation.' | |
| modules: | | |
| [ | |
| { | |
| "name": "ValidatorCore", | |
| "path": "validatorcore", | |
| "description": "Core validation functionality and rules for Swift applications. Contains base types, protocols, and validator implementations.", | |
| "badge": "Core Module" | |
| }, | |
| { | |
| "name": "ValidatorUI", | |
| "path": "validatorui", | |
| "description": "UI components and helpers for building validation interfaces. Ready-to-use solutions for SwiftUI and UIKit.", | |
| "badge": "UI Module" | |
| } | |
| ] | |
| - name: Deploy | |
| uses: peaceiris/actions-gh-pages@v4 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./docs |