v0.9.20 #51
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-and-release: | |
| name: Build (${{ matrix.os }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-22.04 | |
| artifact_name: regenerator2000 | |
| asset_name: regenerator2000-linux-amd64 | |
| - os: ubuntu-24.04-arm | |
| artifact_name: regenerator2000 | |
| asset_name: regenerator2000-linux-arm64 | |
| - os: windows-latest | |
| artifact_name: regenerator2000.exe | |
| asset_name: regenerator2000-windows-amd64 | |
| - os: macos-latest | |
| artifact_name: regenerator2000 | |
| asset_name: regenerator2000-macos-universal | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| # 1. Install Rust (Standard for Linux/Windows) | |
| - name: Install Rust (Linux/Windows) | |
| if: matrix.os != 'macos-latest' | |
| uses: dtolnay/rust-toolchain@stable | |
| # 2. Install Rust (Special for macOS: Install BOTH targets) | |
| - name: Install Rust (macOS) | |
| if: matrix.os == 'macos-latest' | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: x86_64-apple-darwin, aarch64-apple-darwin | |
| # 3. Build (Linux/Windows) | |
| - name: Build (Linux/Windows) | |
| if: matrix.os != 'macos-latest' | |
| run: cargo build --release | |
| # 4. Build Universal Binary (macOS) | |
| - name: Build (macOS Universal) | |
| if: matrix.os == 'macos-latest' | |
| run: | | |
| # Build for Intel | |
| cargo build --release --target x86_64-apple-darwin | |
| # Build for Apple Silicon | |
| cargo build --release --target aarch64-apple-darwin | |
| # Combine them using lipo | |
| lipo -create -output ${{ matrix.artifact_name }} \ | |
| target/x86_64-apple-darwin/release/${{ matrix.artifact_name }} \ | |
| target/aarch64-apple-darwin/release/${{ matrix.artifact_name }} | |
| - name: Code Sign and Notarize (macOS) | |
| if: matrix.os == 'macos-latest' | |
| env: | |
| MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }} | |
| MACOS_CERTIFICATE_PWD: ${{ secrets.MACOS_CERTIFICATE_PWD }} | |
| KEYCHAIN_PWD: ${{ secrets.KEYCHAIN_PWD }} | |
| APPLE_ID: ${{ secrets.APPLE_ID }} | |
| APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }} | |
| APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} | |
| run: | | |
| # Create and configure keychain | |
| security create-keychain -p "$KEYCHAIN_PWD" build.keychain | |
| security default-keychain -s build.keychain | |
| security unlock-keychain -p "$KEYCHAIN_PWD" build.keychain | |
| # Decode and import certificate | |
| echo "$MACOS_CERTIFICATE" | base64 --decode > certificate.p12 | |
| security import certificate.p12 -k build.keychain -P "$MACOS_CERTIFICATE_PWD" -T /usr/bin/codesign | |
| security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PWD" build.keychain | |
| # Get the identity (Developer ID Application) | |
| IDENTITY=$(security find-identity -v -p codesigning | grep "Developer ID Application" | head -1 | awk -F '"' '{print $2}') | |
| if [ -z "$IDENTITY" ]; then | |
| echo "No Developer ID Application identity found. Listing all identities:" | |
| security find-identity -v -p codesigning | |
| exit 1 | |
| fi | |
| echo "Signing with identity: $IDENTITY" | |
| # Code Sign | |
| /usr/bin/codesign --force --options runtime --timestamp --sign "$IDENTITY" ${{ matrix.artifact_name }} -v | |
| # Create zip for notarization | |
| zip -r notarize.zip ${{ matrix.artifact_name }} | |
| # Notarize | |
| xcrun notarytool submit notarize.zip \ | |
| --apple-id "$APPLE_ID" \ | |
| --password "$APPLE_PASSWORD" \ | |
| --team-id "$APPLE_TEAM_ID" \ | |
| --wait | |
| # Cleanup | |
| rm certificate.p12 notarize.zip | |
| # 5. Package (Linux) | |
| - name: Package (Linux) | |
| if: startsWith(matrix.os, 'ubuntu') | |
| run: | | |
| tar -czf ${{ matrix.asset_name }}.tar.gz target/release/${{ matrix.artifact_name }} | |
| # 6. Package (Windows) | |
| - name: Package (Windows) | |
| if: matrix.os == 'windows-latest' | |
| run: | | |
| 7z a ${{ matrix.asset_name }}.zip target/release/${{ matrix.artifact_name }} | |
| # 7. Package (macOS) | |
| - name: Package (macOS) | |
| if: matrix.os == 'macos-latest' | |
| run: | | |
| # We simply compress the universal binary we created in step 4 | |
| tar -czf ${{ matrix.asset_name }}.tar.gz ${{ matrix.artifact_name }} | |
| - name: Upload Release Assets | |
| uses: softprops/action-gh-release@v2 | |
| if: startsWith(github.ref, 'refs/tags/') | |
| with: | |
| files: | | |
| ${{ matrix.asset_name }}.tar.gz | |
| ${{ matrix.asset_name }}.zip | |
| publish: | |
| name: Publish to crates.io | |
| runs-on: ubuntu-latest | |
| needs: build-and-release | |
| if: startsWith(github.ref, 'refs/tags/') | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Publish regenerator2000-core | |
| run: cargo publish -p regenerator2000-core --no-verify | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
| - name: Publish regenerator2000-tui | |
| run: cargo publish -p regenerator2000-tui --no-verify | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
| - name: Publish regenerator2000 | |
| run: cargo publish --no-verify | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} |