|
| 1 | +name: Release binaries |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + tag_name: |
| 9 | + description: 'Tag name to upload assets to (e.g., v0.51.0)' |
| 10 | + required: true |
| 11 | + type: string |
| 12 | + |
| 13 | +permissions: |
| 14 | + contents: write |
| 15 | + |
| 16 | +env: |
| 17 | + GH_TOKEN: ${{ github.token }} |
| 18 | + # Use release tag if triggered by release, otherwise use manual input |
| 19 | + TAG_NAME: ${{ github.event.release.tag_name || inputs.tag_name }} |
| 20 | + |
| 21 | +jobs: |
| 22 | + build: |
| 23 | + name: Build ${{ matrix.artifact_name }} |
| 24 | + strategy: |
| 25 | + fail-fast: false |
| 26 | + matrix: |
| 27 | + include: |
| 28 | + # Linux |
| 29 | + - os: ubuntu-latest |
| 30 | + target: x86_64-unknown-linux-gnu |
| 31 | + artifact_name: pyrefly-linux-x86_64 |
| 32 | + github_env: $GITHUB_ENV |
| 33 | + - os: ubuntu-latest |
| 34 | + target: i686-unknown-linux-gnu |
| 35 | + artifact_name: pyrefly-linux-i686 |
| 36 | + cross: true |
| 37 | + github_env: $GITHUB_ENV |
| 38 | + - os: ubuntu-24.04-arm |
| 39 | + target: aarch64-unknown-linux-gnu |
| 40 | + artifact_name: pyrefly-linux-arm64 |
| 41 | + container: ubuntu:20.04 |
| 42 | + github_env: $GITHUB_ENV |
| 43 | + # macOS |
| 44 | + - os: macos-15-intel |
| 45 | + target: x86_64-apple-darwin |
| 46 | + artifact_name: pyrefly-macos-x86_64 |
| 47 | + github_env: $GITHUB_ENV |
| 48 | + - os: macos-14 |
| 49 | + target: aarch64-apple-darwin |
| 50 | + artifact_name: pyrefly-macos-arm64 |
| 51 | + github_env: $GITHUB_ENV |
| 52 | + # Windows |
| 53 | + - os: windows-latest |
| 54 | + target: x86_64-pc-windows-msvc |
| 55 | + artifact_name: pyrefly-windows-x86_64 |
| 56 | + github_env: $env:GITHUB_ENV |
| 57 | + - os: windows-latest |
| 58 | + target: i686-pc-windows-msvc |
| 59 | + artifact_name: pyrefly-windows-i686 |
| 60 | + cross: true |
| 61 | + github_env: $env:GITHUB_ENV |
| 62 | + - os: windows-latest |
| 63 | + target: aarch64-pc-windows-msvc |
| 64 | + artifact_name: pyrefly-windows-arm64 |
| 65 | + cross: true |
| 66 | + github_env: $env:GITHUB_ENV |
| 67 | + |
| 68 | + runs-on: ${{ matrix.os }} |
| 69 | + container: ${{ matrix.container }} |
| 70 | + |
| 71 | + steps: |
| 72 | + - name: Checkout repository |
| 73 | + uses: actions/checkout@v6 |
| 74 | + with: |
| 75 | + submodules: recursive |
| 76 | + persist-credentials: false |
| 77 | + |
| 78 | + - name: Install container dependencies |
| 79 | + if: matrix.container == 'ubuntu:20.04' |
| 80 | + run: apt-get update && apt-get -y install curl build-essential |
| 81 | + |
| 82 | + - name: Read rust-toolchain file |
| 83 | + run: echo "toolchain=$(cat pyrefly/rust-toolchain)" && echo "toolchain=$(cat pyrefly/rust-toolchain)" >> ${{ matrix.github_env }} |
| 84 | + |
| 85 | + - name: Install Rust toolchain |
| 86 | + uses: dtolnay/rust-toolchain@stable |
| 87 | + with: |
| 88 | + toolchain: ${{ env.toolchain }} |
| 89 | + targets: ${{ matrix.target }} |
| 90 | + |
| 91 | + - name: Set up Rust cache |
| 92 | + uses: Swatinem/rust-cache@v2 |
| 93 | + with: |
| 94 | + prefix-key: pyrefly-release |
| 95 | + |
| 96 | + - name: Set Windows cargo home |
| 97 | + if: runner.os == 'Windows' |
| 98 | + run: echo "CARGO_HOME=C:\cargo" >> ${{ matrix.github_env }} |
| 99 | + |
| 100 | + - name: Set jemalloc page size for ARM64 Linux |
| 101 | + if: matrix.target == 'aarch64-unknown-linux-gnu' |
| 102 | + run: echo "JEMALLOC_SYS_WITH_LG_PAGE=16" >> ${{ matrix.github_env }} |
| 103 | + |
| 104 | + - name: Build binary (native) |
| 105 | + if: ${{ !matrix.cross }} |
| 106 | + run: cargo build --release --manifest-path pyrefly/Cargo.toml -p pyrefly --target ${{ matrix.target }} |
| 107 | + |
| 108 | + - name: Build binary (cross-compile) |
| 109 | + if: ${{ matrix.cross }} |
| 110 | + uses: houseabsolute/actions-rust-cross@v1 |
| 111 | + with: |
| 112 | + command: build |
| 113 | + target: ${{ matrix.target }} |
| 114 | + args: "--release --manifest-path pyrefly/Cargo.toml -p pyrefly" |
| 115 | + toolchain: ${{ env.toolchain }} |
| 116 | + |
| 117 | + - name: Package binary (Unix) |
| 118 | + if: runner.os != 'Windows' |
| 119 | + run: | |
| 120 | + mkdir -p staging |
| 121 | + cp pyrefly/target/${{ matrix.target }}/release/pyrefly staging/ |
| 122 | + cd staging |
| 123 | + tar -czvf ../${{ matrix.artifact_name }}.tar.gz pyrefly |
| 124 | +
|
| 125 | + - name: Package binary (Windows) |
| 126 | + if: runner.os == 'Windows' |
| 127 | + shell: pwsh |
| 128 | + run: | |
| 129 | + New-Item -ItemType Directory -Force -Path staging |
| 130 | + Copy-Item "pyrefly/target/${{ matrix.target }}/release/pyrefly.exe" -Destination staging/ |
| 131 | + Compress-Archive -Path staging/pyrefly.exe -DestinationPath "${{ matrix.artifact_name }}.zip" |
| 132 | +
|
| 133 | + - name: Generate checksum (Unix) |
| 134 | + if: runner.os != 'Windows' |
| 135 | + run: | |
| 136 | + sha256sum ${{ matrix.artifact_name }}.tar.gz > ${{ matrix.artifact_name }}.tar.gz.sha256 |
| 137 | +
|
| 138 | + - name: Generate checksum (Windows) |
| 139 | + if: runner.os == 'Windows' |
| 140 | + shell: pwsh |
| 141 | + run: | |
| 142 | + $hash = (Get-FileHash -Algorithm SHA256 "${{ matrix.artifact_name }}.zip").Hash.ToLower() |
| 143 | + "$hash ${{ matrix.artifact_name }}.zip" | Out-File -Encoding ASCII "${{ matrix.artifact_name }}.zip.sha256" |
| 144 | +
|
| 145 | + - name: Upload to release (Unix) |
| 146 | + if: runner.os != 'Windows' |
| 147 | + run: | |
| 148 | + gh release upload ${{ env.TAG_NAME }} \ |
| 149 | + ${{ matrix.artifact_name }}.tar.gz \ |
| 150 | + ${{ matrix.artifact_name }}.tar.gz.sha256 \ |
| 151 | + --clobber |
| 152 | +
|
| 153 | + - name: Upload to release (Windows) |
| 154 | + if: runner.os == 'Windows' |
| 155 | + shell: pwsh |
| 156 | + run: | |
| 157 | + gh release upload ${{ env.TAG_NAME }} ` |
| 158 | + "${{ matrix.artifact_name }}.zip" ` |
| 159 | + "${{ matrix.artifact_name }}.zip.sha256" ` |
| 160 | + --clobber |
0 commit comments