Refactor release workflow to improve tag validation and output
- Enhanced the release workflow to validate tag formats more robustly, ensuring compliance with semantic versioning. - Added detailed error messages and guidance for users on creating valid tags. - Updated the workflow to use a validated tag for release creation and announcements, improving consistency and clarity in the release process.
This commit is contained in:
52
.github/workflows/release.yml
vendored
52
.github/workflows/release.yml
vendored
@@ -21,22 +21,52 @@ jobs:
|
|||||||
name: Create Release
|
name: Create Release
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
tag_name: ${{ github.ref_name || github.event.inputs.tag }}
|
tag_name: ${{ env.VALIDATED_TAG }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Validate tag format
|
- name: Validate tag format
|
||||||
run: |
|
run: |
|
||||||
TAG="${{ github.ref_name || github.event.inputs.tag }}"
|
# Debug information
|
||||||
|
echo "Event name: ${{ github.event_name }}"
|
||||||
|
echo "Ref: ${{ github.ref }}"
|
||||||
|
echo "Ref name: ${{ github.ref_name }}"
|
||||||
|
echo "Ref type: ${{ github.ref_type }}"
|
||||||
|
|
||||||
|
# Determine the tag based on trigger type
|
||||||
|
if [[ "${{ github.event_name }}" == "push" ]]; then
|
||||||
|
if [[ "${{ github.ref_type }}" != "tag" ]]; then
|
||||||
|
echo "❌ Error: Release workflow triggered by push to ${{ github.ref_type }} '${{ github.ref_name }}'"
|
||||||
|
echo "This workflow should only be triggered by pushing version tags (v1.2.3)"
|
||||||
|
echo "Use: git tag v0.3.0 && git push origin v0.3.0"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
TAG="${{ github.ref_name }}"
|
||||||
|
elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
|
||||||
|
TAG="${{ github.event.inputs.tag }}"
|
||||||
|
if [[ -z "$TAG" ]]; then
|
||||||
|
echo "❌ Error: No tag specified for manual workflow dispatch"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "❌ Error: Unsupported event type: ${{ github.event_name }}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Validating tag: $TAG"
|
echo "Validating tag: $TAG"
|
||||||
|
|
||||||
# Check if tag follows semantic versioning pattern
|
# Check if tag follows semantic versioning pattern
|
||||||
if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-.*)?$ ]]; then
|
if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-.*)?$ ]]; then
|
||||||
echo "❌ Error: Tag '$TAG' does not follow semantic versioning format (v1.2.3 or v1.2.3-beta)"
|
echo "❌ Error: Tag '$TAG' does not follow semantic versioning format (v1.2.3 or v1.2.3-beta)"
|
||||||
echo "Valid examples: v0.3.0, v1.0.0, v2.1.3-beta, v1.0.0-rc1"
|
echo "Valid examples: v0.3.0, v1.0.0, v2.1.3-beta, v1.0.0-rc1"
|
||||||
|
echo ""
|
||||||
|
echo "To create a proper release:"
|
||||||
|
echo "1. Use the helper script: ./scripts/create_release.sh 0.3.0"
|
||||||
|
echo "2. Or manually: git tag v0.3.0 && git push origin v0.3.0"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "✅ Tag format is valid: $TAG"
|
echo "✅ Tag format is valid: $TAG"
|
||||||
|
echo "VALIDATED_TAG=$TAG" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -46,8 +76,8 @@ jobs:
|
|||||||
- name: Generate release notes
|
- name: Generate release notes
|
||||||
id: release_notes
|
id: release_notes
|
||||||
run: |
|
run: |
|
||||||
# Extract release version from tag
|
# Extract release version from validated tag
|
||||||
VERSION="${{ github.ref_name || github.event.inputs.tag }}"
|
VERSION="${VALIDATED_TAG}"
|
||||||
VERSION_NUM=$(echo "$VERSION" | sed 's/^v//')
|
VERSION_NUM=$(echo "$VERSION" | sed 's/^v//')
|
||||||
|
|
||||||
# Generate release notes using the dedicated script
|
# Generate release notes using the dedicated script
|
||||||
@@ -67,11 +97,11 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ github.ref_name || github.event.inputs.tag }}
|
tag_name: ${{ env.VALIDATED_TAG }}
|
||||||
name: Yaze ${{ github.ref_name || github.event.inputs.tag }}
|
name: Yaze ${{ env.VALIDATED_TAG }}
|
||||||
body_path: release_notes.md
|
body_path: release_notes.md
|
||||||
draft: false
|
draft: false
|
||||||
prerelease: ${{ contains(github.ref_name || github.event.inputs.tag, 'beta') || contains(github.ref_name || github.event.inputs.tag, 'alpha') || contains(github.ref_name || github.event.inputs.tag, 'rc') }}
|
prerelease: ${{ contains(env.VALIDATED_TAG, 'beta') || contains(env.VALIDATED_TAG, 'alpha') || contains(env.VALIDATED_TAG, 'rc') }}
|
||||||
generate_release_notes: true
|
generate_release_notes: true
|
||||||
|
|
||||||
build-release:
|
build-release:
|
||||||
@@ -129,7 +159,7 @@ jobs:
|
|||||||
cp LICENSE dmg_staging/
|
cp LICENSE dmg_staging/
|
||||||
cp README.md dmg_staging/
|
cp README.md dmg_staging/
|
||||||
cp -r docs dmg_staging/
|
cp -r docs dmg_staging/
|
||||||
hdiutil create -srcfolder dmg_staging -format UDZO -volname "Yaze ${{ github.ref_name || github.event.inputs.tag }}" yaze-macos.dmg
|
hdiutil create -srcfolder dmg_staging -format UDZO -volname "Yaze ${{ needs.create-release.outputs.tag_name }}" yaze-macos.dmg
|
||||||
|
|
||||||
- name: "Linux x64"
|
- name: "Linux x64"
|
||||||
os: ubuntu-22.04
|
os: ubuntu-22.04
|
||||||
@@ -234,7 +264,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ github.ref_name || github.event.inputs.tag }}
|
tag_name: ${{ needs.create-release.outputs.tag_name }}
|
||||||
files: |
|
files: |
|
||||||
${{ matrix.artifact_name }}.*
|
${{ matrix.artifact_name }}.*
|
||||||
|
|
||||||
@@ -252,6 +282,6 @@ jobs:
|
|||||||
|
|
||||||
- name: Announce release
|
- name: Announce release
|
||||||
run: |
|
run: |
|
||||||
echo "🎉 Yaze ${{ github.ref_name || github.event.inputs.tag }} has been released!"
|
echo "🎉 Yaze ${{ needs.create-release.outputs.tag_name }} has been released!"
|
||||||
echo "📦 Packages are now available for download"
|
echo "📦 Packages are now available for download"
|
||||||
echo "🔗 Release URL: https://github.com/${{ github.repository }}/releases/tag/${{ github.ref_name || github.event.inputs.tag }}"
|
echo "🔗 Release URL: https://github.com/${{ github.repository }}/releases/tag/${{ needs.create-release.outputs.tag_name }}"
|
||||||
|
|||||||
Reference in New Issue
Block a user