diff --git a/.github/workflows/build_python_on_branch.yml b/.github/workflows/build_python_on_branch.yml index 27c60fca..e5e725fb 100644 --- a/.github/workflows/build_python_on_branch.yml +++ b/.github/workflows/build_python_on_branch.yml @@ -47,4 +47,15 @@ jobs: uses: ./.github/workflows/repackage_graalpy.yml with: graalpy_version: ${{ matrix.graalpy_version }} + platforms: "linux-x86_64,linux-aarch64,macos,windows" + + pypy: + name: PyPy ${{ matrix.pypy_version }} + strategy: + fail-fast: false + matrix: + pypy_version: [ 7.3.16 ] + uses: ./.github/workflows/repackage_pypy.yml + with: + pypy_version: ${{ matrix.pypy_version }} platforms: "linux-x86_64,linux-aarch64,macos,windows" \ No newline at end of file diff --git a/.github/workflows/release_pypy.yml b/.github/workflows/release_pypy.yml new file mode 100644 index 00000000..82859ef5 --- /dev/null +++ b/.github/workflows/release_pypy.yml @@ -0,0 +1,92 @@ +name: Build and publish PyPy + +on: + workflow_dispatch: + inputs: + pypy_version: + required: true + type: string + beta: + required: false + type: boolean + default: false + workflow_call: + inputs: + pypy_version: + required: true + type: string + beta: + required: false + type: boolean + default: false + +jobs: + build: + name: Build PyPy ${{ inputs.pypy_version }} + uses: ./.github/workflows/repackage_pypy.yml + with: + pypy_version: ${{ inputs.pypy_version }} + platforms: "linux-x86_64,linux-aarch64,macos,windows" + + publish: + name: Publish PyPy ${{ inputs.pypy_version }} + needs: build + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Get tags + run: git fetch --tags origin + + - name: Download artifact + uses: actions/download-artifact@v4 + with: + pattern: pypy-* + path: /tmp/pypy/ + merge-multiple: true + + - name: Get latest + run: | + echo "LATEST_TAG=$(./scripts/pick_semver.sh ${{ inputs.pypy_version }} ${{ inputs.beta }} pypy true)" >> $GITHUB_ENV + + - name: Pick tag + id: pick_tag + run: | + SELECTED_TAG=$(./scripts/pick_semver.sh ${{ inputs.pypy_version }} ${{ inputs.beta }} pypy) + echo "SELECTED_TAG=$SELECTED_TAG" >> $GITHUB_ENV + echo "::set-output name=release_tag::$SELECTED_TAG" + + - name: Create release + run: | + gh release create ${{ env.SELECTED_TAG }} \ + --title ${{ env.SELECTED_TAG }} \ + --target ${{ github.sha }} \ + ${{ env.LATEST_TAG && format('--generate-notes --notes-start-tag {0}', env.LATEST_TAG) || format('--notes "PyPy {0}"', inputs.pypy_version) }} \ + ${{ inputs.beta && '--prerelease' || '' }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload files + uses: softprops/action-gh-release@v2 + with: + files: /tmp/pypy/pypy*.zip + tag_name: ${{ env.SELECTED_TAG }} + + outputs: + release_tag: ${{ steps.pick_tag.outputs.release_tag }} + + update_installers: + name: Update installers + needs: publish + permissions: + contents: write + uses: ./.github/workflows/update_nodejs_installers.yml + with: + version: ${{ inputs.pypy_version }} + release_tag: ${{ needs.publish.outputs.release_tag }} + beta: ${{ inputs.beta }} + implementation: pypy + secrets: inherit diff --git a/.github/workflows/repackage_pypy.yml b/.github/workflows/repackage_pypy.yml new file mode 100644 index 00000000..bd29b080 --- /dev/null +++ b/.github/workflows/repackage_pypy.yml @@ -0,0 +1,120 @@ +name: Repackage PyPy + +on: + workflow_dispatch: + inputs: + pypy_version: + required: true + type: string + platforms: + required: true + type: string + default: "linux-x86_64,linux-aarch64,macos,windows" + workflow_call: + inputs: + pypy_version: + required: true + type: string + platforms: + required: true + type: string + +env: + image_map: '{"x86_64": "amd64/ubuntu:20.04", "aarch64": "arm64v8/ubuntu:20.04"}' + +jobs: + build_linux: + name: Linux ${{ inputs.pypy_version }} ${{ matrix.arch }} + if: ${{ contains(inputs.platforms, 'linux') }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + arch: [x86_64, aarch64] + exclude: + - arch: ${{ !contains(inputs.platforms, 'linux-x86_64') && 'x86_64' || '' }} + - arch: ${{ !contains(inputs.platforms, 'linux-aarch64') && 'aarch64' || '' }} + + steps: + - name: Parse image + id: parse_image + run: | + IMAGE=$(echo ${{ toJSON(env.image_map) }} | jq -r '.["${{ matrix.arch }}"]') + echo "image=$IMAGE" >> "$GITHUB_OUTPUT" + + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Repackage + uses: addnab/docker-run-action@v3 + with: + image: ${{ steps.parse_image.outputs.image }} + options: -v ${{ github.workspace }}:/work --workdir /work + shell: bash + run: | + set -ex + ./scripts/repackage_pypy.sh ${{ matrix.arch }} ${{ inputs.pypy_version }} linux + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: pypy-linux-${{ matrix.arch }}-${{ inputs.pypy_version }} + path: ./pypy*.zip + + build_windows: + name: Windows ${{ inputs.pypy_version }} x86_64 + if: ${{ contains(inputs.platforms, 'windows') }} + runs-on: windows-latest + + steps: + - name: Set git to use LF + run: | + git config --global core.autocrlf false + git config --global core.eol lf + + - name: Checkout + uses: actions/checkout@v4 + + - name: Repackage + shell: bash + run: | + set -ex + ./scripts/repackage_pypy.sh x86_64 ${{ inputs.pypy_version }} windows + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: pypy-windows-x86_64-${{ inputs.pypy_version }} + path: ./pypy*.zip + + build_macos: + name: MacOS ${{ inputs.pypy_version }} ${{ matrix.arch }} + if: ${{ contains(inputs.platforms, 'macos') }} + runs-on: ${{ matrix.runner }} + strategy: + fail-fast: false + matrix: + arch: [x86_64, aarch64] + include: + - arch: x86_64 + runner: macos-12 + - arch: aarch64 + runner: macos-14 + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Repackage + run: | + set -ex + ./scripts/repackage_pypy.sh ${{ matrix.arch }} ${{ inputs.pypy_version }} darwin + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: pypy-darwin-${{ matrix.arch }}-${{ inputs.pypy_version }} + path: ./pypy*.zip \ No newline at end of file diff --git a/.github/workflows/update_nodejs_installers.yml b/.github/workflows/update_nodejs_installers.yml index 150ced7d..9e1a8546 100644 --- a/.github/workflows/update_nodejs_installers.yml +++ b/.github/workflows/update_nodejs_installers.yml @@ -60,7 +60,7 @@ jobs: - name: Update and publish installers run: | - python ./scripts/update_installer.py ${{ inputs.version }} ${{ inputs.release_tag }} ${{ inputs.implementation}} + python ./scripts/update_installer.py ${{ inputs.version }} ${{ inputs.release_tag }} ${{ inputs.implementation }} cd ./installers/nodejs npm i diff --git a/installers/nodejs/package.json b/installers/nodejs/package.json index 9406cdaf..2453e5a4 100644 --- a/installers/nodejs/package.json +++ b/installers/nodejs/package.json @@ -74,6 +74,10 @@ "versionBuilds": { "24.0.2": "graalpy-v24.0.2-beta.1" } + }, + "pypy": { + "versions": [], + "versionBuilds": {} } } } \ No newline at end of file diff --git a/scripts/repackage_pypy.sh b/scripts/repackage_pypy.sh new file mode 100755 index 00000000..f16fb6bf --- /dev/null +++ b/scripts/repackage_pypy.sh @@ -0,0 +1,82 @@ +#!/bin/bash + +set -e + +ARCH=$1 +PYPY_VERSION=$2 +PLATFORM=$3 + +if [[ "${PLATFORM}" == "linux" ]]; then + echo "::group::Install tools" + apt update && apt -y install zip python3-pip curl + echo "::endgroup::" +fi + +if [[ "${PLATFORM}" == "darwin" ]]; then + python3 -m venv venv + source venv/bin/activate +fi + +python3 -m pip install pyclean + +WORKDIR=$(pwd) + +function repackage_pypy () { + DISTRIBUTION=$1 + echo "::group::PyPy ${DISTRIBUTION}" + + if [[ "${PLATFORM}" == "linux" ]]; then + if [[ "${ARCH}" == "x86_64" ]]; then + DL_LINK=https://downloads.python.org/pypy/pypy${DISTRIBUTION}-v${PYPY_VERSION}-linux64.tar.bz2 + DL_FILENAME=pypy${DISTRIBUTION}-v${PYPY_VERSION}-linux64 + else + DL_LINK=https://downloads.python.org/pypy/pypy${DISTRIBUTION}-v${PYPY_VERSION}-aarch64.tar.bz2 + DL_FILENAME=pypy${DISTRIBUTION}-v${PYPY_VERSION}-aarch64 + fi + elif [[ "${PLATFORM}" == "darwin" ]]; then + if [[ "${ARCH}" == "x86_64" ]]; then + DL_LINK=https://downloads.python.org/pypy/pypy${DISTRIBUTION}-v${PYPY_VERSION}-macos_x86_64.tar.bz2 + DL_FILENAME=pypy${DISTRIBUTION}-v${PYPY_VERSION}-macos_x86_64 + else + DL_LINK=https://downloads.python.org/pypy/pypy${DISTRIBUTION}-v${PYPY_VERSION}-macos_arm64.tar.bz2 + DL_FILENAME=pypy${DISTRIBUTION}-v${PYPY_VERSION}-macos_arm64 + fi + elif [[ "${PLATFORM}" == "windows" ]]; then + DL_LINK=https://downloads.python.org/pypy/pypy${DISTRIBUTION}-v${PYPY_VERSION}-win64.zip + DL_FILENAME=pypy${DISTRIBUTION}-v${PYPY_VERSION}-win64 + fi + UPLOAD_FILENAME=pypy${DISTRIBUTION}-${PYPY_VERSION}-${PLATFORM}-${ARCH} + + if [[ "${PLATFORM}" == "windows" ]]; then + curl -L ${DL_LINK} --output ${DL_FILENAME}.zip + 7z.exe x ${DL_FILENAME}.zip + rm ${DL_FILENAME}.zip + else + curl -L ${DL_LINK} --output ${DL_FILENAME}.tar.bz2 + tar -xf ${DL_FILENAME}.tar.bz2 + rm ${DL_FILENAME}.tar.bz2 + fi + + cd ${DL_FILENAME} + if [[ "${PLATFORM}" == "windows" ]]; then + ./python -m ensurepip + else + ./bin/python -m ensurepip + fi + + cd ${WORKDIR} + mv ${DL_FILENAME} ${UPLOAD_FILENAME} + + python3 -m pyclean -v ${UPLOAD_FILENAME} + tar -czf ${WORKDIR}/${UPLOAD_FILENAME}.tar.gz ${UPLOAD_FILENAME} + if [[ "${PLATFORM}" == "windows" ]]; then + 7z.exe a ${WORKDIR}/${UPLOAD_FILENAME}.zip ${UPLOAD_FILENAME} + else + zip ${WORKDIR}/${UPLOAD_FILENAME}.zip $(tar tf ${WORKDIR}/${UPLOAD_FILENAME}.tar.gz) + fi + + echo "::endgroup::" +} + +repackage_pypy 3.10 +repackage_pypy 3.9