Merge pull request #33 from pyozig/dev #33
Workflow file for this run
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: Release | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| name: Build Release Binaries | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Zig | |
| uses: goto-bus-stop/setup-zig@v2 | |
| with: | |
| version: 0.15.2 | |
| - name: Cache Zig | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cache/zig | |
| zig-cache | |
| key: zig-cache-${{ runner.os }}-${{ hashFiles('build.zig', 'build.zig.zon') }} | |
| restore-keys: | | |
| zig-cache-${{ runner.os }}- | |
| - name: Build all platforms | |
| run: zig build release | |
| - name: Create source tarball | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| git archive --format=tar.gz --prefix=PyOZ-${VERSION}/ -o zig-out/release/PyOZ-${VERSION}.tar.gz HEAD | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: release-binaries | |
| path: zig-out/release/* | |
| release: | |
| name: Create GitHub Release | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: release-binaries | |
| path: release/ | |
| - name: Get version from tag | |
| id: version | |
| run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT | |
| - name: Extract changelog for this version | |
| id: changelog | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| # Extract the section between this version and the next version header (or end of file) | |
| CHANGELOG=$(awk -v ver="$VERSION" ' | |
| BEGIN { found=0; output="" } | |
| /^## \[/ { | |
| if (found) exit | |
| if (index($0, ver)) found=1 | |
| next | |
| } | |
| found { output = output $0 "\n" } | |
| END { print output } | |
| ' CHANGELOG.md) | |
| # Write to file to preserve newlines | |
| echo "$CHANGELOG" > changelog_section.txt | |
| # Also set as output (escaped for GitHub Actions) | |
| { | |
| echo 'NOTES<<EOF' | |
| cat changelog_section.txt | |
| echo 'EOF' | |
| } >> $GITHUB_OUTPUT | |
| - name: Create Release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| VERSION=${{ steps.version.outputs.VERSION }} | |
| PRERELEASE_FLAG="" | |
| if [[ "$VERSION" == *alpha* ]] || [[ "$VERSION" == *beta* ]] || [[ "$VERSION" == *rc* ]]; then | |
| PRERELEASE_FLAG="--prerelease" | |
| fi | |
| cat > release_notes.md << 'RELEASE_EOF' | |
| ## What's New in v${{ steps.version.outputs.VERSION }} | |
| ${{ steps.changelog.outputs.NOTES }} | |
| --- | |
| ## Installation | |
| Download the binary for your platform and add it to your PATH: | |
| | Platform | Binary | | |
| |----------|--------| | |
| | Linux x86_64 | `pyoz-x86_64-linux` | | |
| | Linux ARM64 | `pyoz-aarch64-linux` | | |
| | macOS x86_64 | `pyoz-x86_64-macos` | | |
| | macOS ARM64 (Apple Silicon) | `pyoz-aarch64-macos` | | |
| | Windows x86_64 | `pyoz-x86_64-windows.exe` | | |
| | Windows ARM64 | `pyoz-aarch64-windows.exe` | | |
| ## Source | |
| Download `PyOZ-${{ steps.version.outputs.VERSION }}.tar.gz` for the source code. | |
| ## Quick Start | |
| ```bash | |
| pyoz init mymodule | |
| cd mymodule | |
| pyoz build | |
| pip install dist/*.whl | |
| ``` | |
| RELEASE_EOF | |
| gh release create "v${VERSION}" \ | |
| --title "PyOZ v${VERSION}" \ | |
| --notes-file release_notes.md \ | |
| $PRERELEASE_FLAG \ | |
| release/* | |
| pypi: | |
| name: Publish to PyPI | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Zig | |
| uses: goto-bus-stop/setup-zig@v2 | |
| with: | |
| version: 0.15.2 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Cache Zig | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cache/zig | |
| pypi/zig-cache | |
| key: zig-pypi-cache-${{ runner.os }}-${{ hashFiles('pypi/build.zig', 'pypi/build.zig.zon') }} | |
| restore-keys: | | |
| zig-pypi-cache-${{ runner.os }}- | |
| - name: Build abi3 wheels for all platforms | |
| run: python pypi/build_wheels.py --dist-dir pypi/dist | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| password: ${{ secrets.PYPI_API_TOKEN }} | |
| packages-dir: pypi/dist/ | |
| skip-existing: true |