This repository was archived by the owner on Jul 29, 2026. It is now read-only.
ci: update .circleci/config.yml #9
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: Create Release (Reusable) | ||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| version: | ||
| required: true | ||
| type: string | ||
| description: 'Release version (e.g., 1.0.0)' | ||
| draft: | ||
| required: false | ||
| type: boolean | ||
| default: false | ||
| description: 'Create as draft release' | ||
| prerelease: | ||
| required: false | ||
| type: boolean | ||
| default: false | ||
| description: 'Mark as pre-release' | ||
| generate-notes: | ||
| required: false | ||
| type: boolean | ||
| default: true | ||
| description: 'Auto-generate release notes' | ||
| discussion-category: | ||
| required: false | ||
| type: string | ||
| default: '' | ||
| description: 'Create discussion in this category' | ||
| artifact-paths: | ||
| required: false | ||
| type: string | ||
| default: '' | ||
| description: 'Comma-separated paths to artifacts to upload' | ||
| artifact-name-pattern: | ||
| required: false | ||
| type: string | ||
| default: '*' | ||
| description: 'Pattern to match artifact names' | ||
| secrets: | ||
| GITHUB_TOKEN: | ||
| required: true | ||
| jobs: | ||
| release: | ||
| name: Create GitHub Release | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| discussions: write | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: Validate version format | ||
| run: | | ||
| if [[ ! "${{ inputs.version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?$ ]]; then | ||
| echo "Error: Version must be in semantic versioning format (e.g., 1.0.0 or 1.0.0-beta)" | ||
| exit 1 | ||
| fi | ||
| - name: Ensure tag exists | ||
| run: | | ||
| TAG="v${{ inputs.version }}" | ||
| if ! git rev-parse "$TAG" >/dev/null 2>&1; then | ||
| echo "Creating tag $TAG" | ||
| git tag "$TAG" | ||
| git push origin "$TAG" | ||
| else | ||
| echo "Tag $TAG already exists" | ||
| fi | ||
| - name: Download artifacts | ||
| if: inputs.artifact-name-pattern != '' | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| pattern: ${{ inputs.artifact-name-pattern }} | ||
| path: ./artifacts | ||
| merge-multiple: true | ||
| - name: Prepare release assets | ||
| if: inputs.artifact-paths != '' | ||
| run: | | ||
| mkdir -p ./release-assets | ||
| IFS=',' read -ra PATHS <<< "${{ inputs.artifact-paths }}" | ||
| for path in "${PATHS[@]}"; do | ||
| if [ -e "$path" ]; then | ||
| cp -r "$path" ./release-assets/ | ||
| echo "Added: $path" | ||
| fi | ||
| done | ||
| - name: Create Release | ||
| uses: ncipollo/release-action@v1 | ||
| with: | ||
| tag: v${{ inputs.version }} | ||
| name: Release v${{ inputs.version }} | ||
| draft: ${{ inputs.draft }} | ||
| prerelease: ${{ inputs.prerelease }} | ||
| generateReleaseNotes: ${{ inputs.generate-notes }} | ||
| discussionCategory: ${{ inputs.discussion-category }} | ||
| artifacts: "./release-assets/*,./artifacts/*" | ||
| artifactErrorsFailBuild: false | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Release Summary | ||
| run: | | ||
| echo "## Release Created" >> $GITHUB_STEP_SUMMARY | ||
| echo "- **Version:** v${{ inputs.version }}" >> $GITHUB_STEP_SUMMARY | ||
| echo "- **Draft:** ${{ inputs.draft }}" >> $GITHUB_STEP_SUMMARY | ||
| echo "- **Pre-release:** ${{ inputs.prerelease }}" >> $GITHUB_STEP_SUMMARY | ||
| echo "- **URL:** https://github.com/${{ github.repository }}/releases/tag/v${{ inputs.version }}" >> $GITHUB_STEP_SUMMARY | ||