From 7c0030b7117ac16119ed3dd0931189434bc766f2 Mon Sep 17 00:00:00 2001 From: Brett Jia Date: Sat, 3 Aug 2024 20:47:16 -0400 Subject: [PATCH] graalpy release job + prefix releases with implementation --- .github/workflows/build_python.yml | 2 +- .github/workflows/release_graalpy.yml | 92 +++++++++++++++++++++++++++ .github/workflows/release_python.yml | 10 +-- scripts/pick_semver.sh | 12 ++-- 4 files changed, 105 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/release_graalpy.yml diff --git a/.github/workflows/build_python.yml b/.github/workflows/build_python.yml index b384c935..d1e32c65 100644 --- a/.github/workflows/build_python.yml +++ b/.github/workflows/build_python.yml @@ -1,4 +1,4 @@ -name: Build Python +name: Build CPython on: workflow_dispatch: diff --git a/.github/workflows/release_graalpy.yml b/.github/workflows/release_graalpy.yml new file mode 100644 index 00000000..e33a6895 --- /dev/null +++ b/.github/workflows/release_graalpy.yml @@ -0,0 +1,92 @@ +name: Build and publish GraalPy + +on: + workflow_dispatch: + inputs: + graalpy_version: + required: true + type: string + beta: + required: false + type: boolean + default: false + workflow_call: + inputs: + graalpy_version: + required: true + type: string + beta: + required: false + type: boolean + default: false + +jobs: + build: + name: Build GraalPy ${{ inputs.graalpy_version }} + uses: ./.github/workflows/repackage_graalpy.yml + with: + graalpy_version: ${{ inputs.graalpy_version }} + platforms: "linux-x86_64,linux-aarch64,macos,windows" + + publish: + name: Publish GraalPy ${{ inputs.graalpy_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: graalpy-* + path: /tmp/graalpy/ + merge-multiple: true + + - name: Get latest + run: | + echo "LATEST_TAG=$(./scripts/pick_semver.sh ${{ inputs.graalpy_version }} ${{ inputs.beta }} true)" >> $GITHUB_ENV + + - name: Pick tag + id: pick_tag + run: | + SELECTED_TAG=$(./scripts/pick_semver.sh ${{ inputs.graalpy_version }} ${{ inputs.beta }}) + 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 "Python {0}"', inputs.graalpy_version) }} \ + ${{ inputs.beta && '--prerelease' || '' }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload files + uses: softprops/action-gh-release@v2 + with: + files: /tmp/graalpy/graalpy*.zip + tag_name: ${{ env.SELECTED_TAG }} + + outputs: + release_tag: ${{ steps.pick_tag.outputs.release_tag }} + + update_installers: + if: false + name: Update installers + needs: publish + permissions: + contents: write + uses: ./.github/workflows/update_nodejs_installers.yml + with: + graalpy_version: ${{ inputs.graalpy_version }} + release_tag: ${{ needs.publish.outputs.release_tag }} + beta: ${{ inputs.beta }} + secrets: inherit diff --git a/.github/workflows/release_python.yml b/.github/workflows/release_python.yml index 8767525c..cca6e8d6 100644 --- a/.github/workflows/release_python.yml +++ b/.github/workflows/release_python.yml @@ -1,4 +1,4 @@ -name: Build and publish Python +name: Build and publish CPython on: workflow_dispatch: @@ -22,14 +22,14 @@ on: jobs: build: - name: Build ${{ inputs.python_version }} + name: Build CPython ${{ inputs.python_version }} uses: ./.github/workflows/build_python.yml with: python_version: ${{ inputs.python_version }} platforms: "linux-x86_64,linux-aarch64,linux-i386,linux-arm,linux-riscv64,macos,windows,cosmo,freebsd13-x86_64,freebsd14-x86_64" publish: - name: Publish ${{ inputs.python_version }} + name: Publish CPython ${{ inputs.python_version }} needs: build runs-on: ubuntu-latest permissions: @@ -50,12 +50,12 @@ jobs: - name: Get latest run: | - echo "LATEST_TAG=$(./scripts/pick_semver.sh ${{ inputs.python_version }} ${{ inputs.beta }} true)" >> $GITHUB_ENV + echo "LATEST_TAG=$(./scripts/pick_semver.sh ${{ inputs.python_version }} ${{ inputs.beta }} cpython true)" >> $GITHUB_ENV - name: Pick tag id: pick_tag run: | - SELECTED_TAG=$(./scripts/pick_semver.sh ${{ inputs.python_version }} ${{ inputs.beta }}) + SELECTED_TAG=$(./scripts/pick_semver.sh ${{ inputs.python_version }} ${{ inputs.beta }} cpython) echo "SELECTED_TAG=$SELECTED_TAG" >> $GITHUB_ENV echo "::set-output name=release_tag::$SELECTED_TAG" diff --git a/scripts/pick_semver.sh b/scripts/pick_semver.sh index a43fd0ed..5fcf424f 100755 --- a/scripts/pick_semver.sh +++ b/scripts/pick_semver.sh @@ -2,15 +2,17 @@ python_version=$1 beta=$2 -print_latest=$3 +implementation=$3 +print_latest=$4 +prefix=$implementation suffix=build if [[ "$beta" == "true" ]]; then suffix=beta fi -tags=$(git tag | grep "$python_version-$suffix") +tags=$(git tag | grep "$prefix-v$python_version-$suffix") if [[ -z "$tags" ]]; then if [[ "$print_latest" != "true" ]]; then @@ -21,14 +23,14 @@ fi most_recent=0 while read tag; do - tag_postfix=$(echo $tag | sed "s/^v$python_version-$suffix\.//") + tag_postfix=$(echo $tag | sed "s/^$prefix-v$python_version-$suffix\.//") if [ "$tag_postfix" -gt "$most_recent" ]; then most_recent=$tag_postfix fi done <<< "$tags" if [[ "$print_latest" == "true" ]]; then - echo "v$python_version-$suffix.$most_recent" + echo "$prefix-v$python_version-$suffix.$most_recent" else - echo "v$python_version-$suffix.$(expr $most_recent + 1)" + echo "$prefix-v$python_version-$suffix.$(expr $most_recent + 1)" fi \ No newline at end of file