Build and Release #8
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: Build and Release | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Version (X.Y.Z) when manually dispatching without a tag" | |
| required: false | |
| type: string | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Determine version | |
| id: vars | |
| run: | | |
| if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then | |
| ref="${GITHUB_REF##*/}" | |
| ver="${ref#v}" | |
| echo "Detected tag: $ref" | |
| echo "tag=$ref" >> $GITHUB_OUTPUT | |
| echo "version=$ver" >> $GITHUB_OUTPUT | |
| else | |
| manual_ver='${{ inputs.version }}' | |
| if [[ -z "$manual_ver" ]]; then | |
| ver=$(grep -E "version': \(" __init__.py | head -n1 | sed -E "s/.*version': \(([^)]*)\).*/\1/" | tr -d ' ' | cut -d',' -f1-3 | tr ',' '.') | |
| echo "Parsed version from __init__.py: $ver" | |
| else | |
| ver="$manual_ver" | |
| echo "Using provided version input: $ver" | |
| fi | |
| tag="v$ver" | |
| echo "tag=$tag" >> $GITHUB_OUTPUT | |
| echo "version=$ver" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Ensure tag exists (manual dispatch) | |
| if: startsWith(github.ref, 'refs/tags/') == false | |
| run: | | |
| git config user.name "github-actions" | |
| git config user.email "actions@users.noreply.github.com" | |
| git fetch --tags | |
| if git rev-parse "${{ steps.vars.outputs.tag }}" >/dev/null 2>&1; then | |
| echo "Tag ${{ steps.vars.outputs.tag }} already exists locally."; | |
| else | |
| git tag -a "${{ steps.vars.outputs.tag }}" -m "Release ${{ steps.vars.outputs.version }}"; | |
| fi | |
| git push origin "${{ steps.vars.outputs.tag }}" || echo "Tag push may have failed if tag already remote." | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.x" | |
| - name: Package addon | |
| run: | | |
| python scripts/package_addon.py --version ${{ steps.vars.outputs.version }} | |
| ls -l dist || true | |
| ls -l *.zip | |
| - name: Generate release notes (diff from previous tag) | |
| id: notes | |
| run: | | |
| CURRENT=${{ steps.vars.outputs.tag }} | |
| PREV=$(git tag --sort=-creatordate | grep -v "$CURRENT" | head -n1 || true) | |
| if [ -n "$PREV" ]; then | |
| echo "Changes since $PREV" > notes.txt | |
| git log --oneline "$PREV".."$CURRENT" >> notes.txt | |
| else | |
| echo "Initial release" > notes.txt | |
| fi | |
| echo "file=notes.txt" >> $GITHUB_OUTPUT | |
| - name: Upload artifact (zip) | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: addon-zip | |
| path: render-queue-manager-v${{ steps.vars.outputs.version }}.zip | |
| - name: Create release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| name: Render Queue Manager ${{ steps.vars.outputs.version }} | |
| tag_name: ${{ steps.vars.outputs.tag }} | |
| body_path: notes.txt | |
| files: render-queue-manager-v${{ steps.vars.outputs.version }}.zip | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |