Create Release #10
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 | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version_bump: | |
| description: "Select the version bump type" | |
| required: true | |
| default: "patch" | |
| type: choice | |
| options: | |
| - none | |
| - patch | |
| - minor | |
| - major | |
| jobs: | |
| prepare_release: | |
| runs-on: windows-latest # Run this job on a single OS | |
| outputs: | |
| app_version: ${{ steps.get_version.outputs.APP_VERSION }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.13" | |
| architecture: x64 | |
| - name: Install dependencies | |
| run: python -m pip install -r requirements.txt --upgrade | |
| - name: Bump and Commit Version | |
| if: github.event.inputs.version_bump != 'none' | |
| run: | | |
| new_version=$(python bump_version.py ${{ github.event.inputs.version_bump }}) | |
| git config --global user.name 'github-actions[bot]' | |
| git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
| git add src/utils/version.py | |
| git commit -m "Bump version to $new_version" | |
| shell: bash | |
| - name: Push changes | |
| if: github.event.inputs.version_bump != 'none' | |
| uses: ad-m/github-push-action@v0.6.0 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| branch: ${{ github.ref }} | |
| - name: Move tag to latest commit if bump is none | |
| if: github.event.inputs.version_bump == 'none' | |
| run: | | |
| git fetch --tags | |
| version=$(python -c "from src.utils.version import APP_VERSION; print(APP_VERSION)") | |
| tag_name="v$version" | |
| git tag -d $tag_name || true | |
| git push --delete origin $tag_name || true | |
| git tag $tag_name | |
| git push origin $tag_name | |
| shell: bash | |
| - name: Get Version | |
| id: get_version | |
| run: | | |
| version=$(python -c "from src.utils.version import APP_VERSION; print(APP_VERSION)") | |
| echo "APP_VERSION=$version" >> $GITHUB_OUTPUT | |
| shell: bash | |
| build: | |
| runs-on: ${{ matrix.os }} | |
| needs: prepare_release # This job depends on prepare_release | |
| strategy: | |
| matrix: | |
| os: [windows-latest, macos-latest] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.13" | |
| architecture: x64 | |
| - name: Install dependencies | |
| run: python -m pip install -r requirements.txt --upgrade | |
| - name: Bundle application (Windows) | |
| if: runner.os == 'Windows' | |
| run: powershell -ExecutionPolicy Bypass -File .\bundle_app_windows.ps1 | |
| shell: pwsh | |
| - name: Bundle application (macOS) | |
| if: runner.os == 'macOS' | |
| run: bash ./bundle_app_macos.sh | |
| shell: bash | |
| - name: Upload to GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: v${{ needs.prepare_release.outputs.app_version }} | |
| files: ./dist/NITools_${{ runner.os }}_v${{ needs.prepare_release.outputs.app_version }}.zip | |
| name: Release v${{ needs.prepare_release.outputs.app_version }} | |
| draft: false | |
| prerelease: false | |
| generate_release_notes: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |