Release MultiAnnouncer Manually #9
This file contains 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 MultiAnnouncer | |
on: | |
pull_request: | |
types: [closed] | |
branches: | |
- main | |
workflow_dispatch: | |
inputs: | |
versionType: | |
description: 'Select the version bump type for manual trigger' | |
required: false | |
default: 'patch' | |
type: choice | |
options: | |
- patch | |
- minor | |
- major | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
if: > | |
github.event.pull_request.merged == true || | |
github.event_name == 'workflow_dispatch' | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
with: | |
ref: 'main' | |
- name: Setup Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.x' | |
- name: Bump Version in TOC file (for manual trigger) | |
if: github.event_name == 'workflow_dispatch' | |
run: python .github/scripts/bump_version.py ${{ github.event.inputs.versionType }} | |
env: | |
VERSION_TYPE: ${{ github.event.inputs.versionType }} | |
- name: Bump Version in TOC file (for PR merge) | |
if: github.event.pull_request.merged == true | |
run: python .github/scripts/bump_version.py auto | |
env: | |
VERSION_TYPE: auto | |
- name: Get the new version number | |
id: get_version | |
run: echo "::set-output name=VERSION::$(grep '^## Version:' MultiAnnouncer.toc | cut -d ' ' -f3)" | |
- name: Commit updated TOC file | |
run: | | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
git add MultiAnnouncer.toc | |
git commit -m "Bump version to ${{ steps.get_version.outputs.VERSION }}" || echo "No changes to commit" | |
git push | |
- name: Generate CHANGELOG.md | |
run: | | |
LAST_TAG=$(git describe --tags --abbrev=0) | |
echo "## Changelog since $LAST_TAG" > CHANGELOG.md | |
echo "" >> CHANGELOG.md | |
git log ${LAST_TAG}..HEAD --pretty=format:"- %s" --reverse >> CHANGELOG.md | |
- name: Generate release.json | |
run: | | |
VERSION=$(grep '^## Version:' MultiAnnouncer.toc | cut -d ' ' -f3) | |
MAINLINE=$(jq -r '.versions.mainline' .github/versions.json) | |
WRATH=$(jq -r '.versions.wrath' .github/versions.json) | |
CLASSIC=$(jq -r '.versions.classic' .github/versions.json) | |
cat > release.json << EOF | |
{ | |
"releases": [ | |
{ | |
"name": "MultiAnnouncer", | |
"version": "$VERSION", | |
"filename": "MultiAnnouncer-$VERSION.zip", | |
"nolib": false, | |
"metadata": [ | |
{ | |
"flavor": "mainline", | |
"interface": $MAINLINE | |
}, | |
{ | |
"flavor": "wrath", | |
"interface": $WRATH | |
}, | |
{ | |
"flavor": "classic", | |
"interface": $CLASSIC | |
} | |
] | |
} | |
] | |
} | |
EOF | |
shell: bash | |
- name: Generate version-specific TOC files | |
run: python .github/scripts/generate_toc_versions.py | |
- name: Zip Addon Files | |
run: | | |
mkdir -p package/MultiAnnouncer | |
rsync -av --exclude='package/' ./* package/MultiAnnouncer/ | |
cd package | |
zip -r ../MultiAnnouncer-${{ steps.get_version.outputs.VERSION }}.zip MultiAnnouncer/ -x "*.git*" -x "*__pycache__*" -x "*.github*" | |
cd .. | |
rm -rf package | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ steps.get_version.outputs.VERSION }} | |
release_name: Release v${{ steps.get_version.outputs.VERSION }} | |
body: "New release of MultiAnnouncer." | |
draft: false | |
prerelease: false | |
- name: Upload Release Asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./MultiAnnouncer-${{ steps.get_version.outputs.VERSION }}.zip | |
asset_name: MultiAnnouncer-${{ steps.get_version.outputs.VERSION }}.zip | |
asset_content_type: application/zip |