Publish Legacy Releases #7
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: Publish Legacy Releases | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: 'The existing tag to create a release for (e.g., 2.0.0)' | |
| required: true | |
| type: string | |
| jobs: | |
| publish: | |
| name: Release Legacy on GitHub | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout next branch | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: next | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| - name: Extract version from input tag | |
| id: get_version | |
| run: | | |
| # Get tag from workflow input | |
| FULL_TAG="${{ inputs.tag }}" | |
| # Validate tag format | |
| if [[ ! $FULL_TAG =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.*)?$ ]]; then | |
| echo "ERROR: Tag '$FULL_TAG' does not match format {VERSION}" | |
| echo "Expected format: 1.2.3 or 2.0.0-beta1" | |
| exit 1 | |
| fi | |
| # Verify the tag exists | |
| if ! git rev-parse "refs/tags/$FULL_TAG" >/dev/null 2>&1; then | |
| echo "ERROR: Tag '$FULL_TAG' does not exist in the repository." | |
| exit 1 | |
| fi | |
| # Extract version part (strip roman numeral prefix) | |
| VERSION=${FULL_TAG} | |
| # Detect if this is a pre-release version | |
| if [[ $VERSION =~ - ]]; then | |
| IS_PRERELEASE="true" | |
| else | |
| IS_PRERELEASE="false" | |
| fi | |
| # Extract major.minor.patch and create cleaned version string | |
| if [[ $VERSION =~ ^([0-9]+)\.([0-9]+)\.([0-9]+) ]]; then | |
| MAJOR="${BASH_REMATCH[1]}" | |
| MINOR="${BASH_REMATCH[2]}" | |
| PATCH="${BASH_REMATCH[3]}" | |
| VERSION_TRIMMED="${MAJOR}.${MINOR}.${PATCH}" | |
| VERSION_CLEAN="_${MAJOR}_${MINOR}_${PATCH}" | |
| else | |
| VERSION_TRIMMED="" | |
| VERSION_CLEAN="" | |
| fi | |
| echo "full_tag=$FULL_TAG" >> $GITHUB_OUTPUT | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "version_trimmed=$VERSION_TRIMMED" >> $GITHUB_OUTPUT | |
| echo "is_prerelease=$IS_PRERELEASE" >> $GITHUB_OUTPUT | |
| echo "version_clean=$VERSION_CLEAN" >> $GITHUB_OUTPUT | |
| echo "Input tag: $FULL_TAG" | |
| echo "Version: $VERSION" | |
| echo "Version trimmed: $VERSION_TRIMMED" | |
| echo "Is pre-release: $IS_PRERELEASE" | |
| echo "Version clean: $VERSION_CLEAN" | |
| - name: Create release notes | |
| id: create_release_notes | |
| run: | | |
| CHANGELOG_FILE="docs/modules/ROOT/partials/changelog-${{ steps.get_version.outputs.version_trimmed }}.adoc" | |
| if [ ! -f "$CHANGELOG_FILE" ]; then | |
| echo "ERROR: Changelog file '$CHANGELOG_FILE' not found." | |
| exit 1 | |
| fi | |
| # Convert AsciiDoc to Markdown using downdoc | |
| npx downdoc "$CHANGELOG_FILE" -o release_notes.md | |
| # Build the release body | |
| { | |
| cat release_notes.md | |
| echo "" | |
| echo "" | |
| echo "<br />" | |
| echo "" | |
| echo "[View full changelog →](https://peopleware.github.io/net-ppwcode-docs/ppwcode-api-core/changelog.html#${{ steps.get_version.outputs.version_clean }})" | |
| } > release_body.md | |
| - name: Add Release Notes to Job Summary | |
| run: | | |
| if [ -f release_body.md ]; then | |
| echo "# PPWCode.API.Core ${{ steps.get_version.outputs.version }}" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| cat release_body.md >> $GITHUB_STEP_SUMMARY | |
| fi | |
| - name: Create GitHub Release | |
| if: steps.get_version.outputs.is_prerelease == 'false' | |
| uses: softprops/action-gh-release@v2.4.2 | |
| with: | |
| tag_name: ${{ steps.get_version.outputs.full_tag }} | |
| generate_release_notes: false | |
| make_latest: false | |
| name: PPWCode.API.Core ${{ steps.get_version.outputs.version }} | |
| body_path: release_body.md |