Skip to content

Commit

Permalink
graalpy release job + prefix releases with implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
bjia56 authored Aug 4, 2024
1 parent fedeea9 commit 7c0030b
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_python.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build Python
name: Build CPython

on:
workflow_dispatch:
Expand Down
92 changes: 92 additions & 0 deletions .github/workflows/release_graalpy.yml
Original file line number Diff line number Diff line change
@@ -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
10 changes: 5 additions & 5 deletions .github/workflows/release_python.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and publish Python
name: Build and publish CPython

on:
workflow_dispatch:
Expand All @@ -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:
Expand All @@ -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"
Expand Down
12 changes: 7 additions & 5 deletions scripts/pick_semver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit 7c0030b

Please sign in to comment.