Update build.yml #4
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 Nuitka Standalone | |
| on: | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| contents: write | |
| pages: write | |
| id-token: write | |
| pull-requests: write | |
| issues: write | |
| actions: read | |
| checks: write | |
| env: | |
| PACKAGE_VERSION: 0.1.0 | |
| jobs: | |
| build: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [windows-latest, ubuntu-latest, macos-latest] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@main | |
| - name: Set up Python | |
| uses: actions/setup-python@main | |
| with: | |
| python-version: "3.12" | |
| architecture: "x64" | |
| cache: "pip" | |
| cache-dependency-path: | | |
| **/requirements*.txt | |
| - name: Install Dependencies | |
| run: | | |
| pip install -r requirements-repo.txt | |
| - name: Build Executable with Nuitka | |
| uses: Nuitka/Nuitka-Action@main | |
| with: | |
| nuitka-version: main | |
| script-name: build.py | |
| mode: app | |
| # Add any other Nuitka options you need | |
| - name: Upload Nuitka build artifact | |
| uses: actions/upload-artifact@main | |
| with: | |
| name: ${{ runner.os }} Build | |
| path: | | |
| build/*.exe | |
| build/*.bin | |
| build/*.app/**/* | |
| include-hidden-files: true | |
| release: | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@main | |
| with: | |
| fetch-depth: 0 | |
| - name: Download all build artifacts | |
| uses: actions/download-artifact@main | |
| with: | |
| path: ./build | |
| - name: Get latest tag | |
| id: get_tag | |
| shell: bash | |
| run: | | |
| latest_tag=$(git tag | sort -V | tail -n 1) | |
| if [ -z "$latest_tag" ]; then | |
| new_tag="v${{ env.PACKAGE_VERSION }}" | |
| else | |
| random_str=$(openssl rand -hex 4) | |
| version_prefix=${{ env.PACKAGE_VERSION }} | |
| new_tag="${version_prefix}-${random_str}" | |
| fi | |
| echo "LATEST_TAG=$new_tag" >> $GITHUB_ENV | |
| - name: Create tag | |
| run: | | |
| git tag ${{ env.LATEST_TAG }} | |
| git push origin ${{ env.LATEST_TAG }} | |
| - name: Create GitHub release | |
| id: create_release | |
| uses: softprops/action-gh-release@c43d7637b9b9ce3e953168c325d27253a5d48d8e | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: ${{ env.LATEST_TAG }} | |
| name: v${{ env.PACKAGE_VERSION }} | |
| body: | | |
| Release version ${{ env.PACKAGE_VERSION }} of the project. | |
| - name: Display the release directory structure | |
| run: ls -R ./build | |
| - name: Upload Release Assets | |
| run: | | |
| for file in ./build/**/*; do | |
| if [ -f "$file" ]; then | |
| gh release upload "${{ env.LATEST_TAG }}" "$file" --clobber | |
| fi | |
| done | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |