From e814569e30f584a749cf59ad6aa9728d5adb2788 Mon Sep 17 00:00:00 2001 From: Hamza REMMAL Date: Sat, 8 Jun 2024 19:47:34 +0100 Subject: [PATCH 1/4] Add reusable workflow for SDKMAN! release --- .github/workflows/release-sdkman.yml | 69 ++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 .github/workflows/release-sdkman.yml diff --git a/.github/workflows/release-sdkman.yml b/.github/workflows/release-sdkman.yml new file mode 100644 index 000000000000..270b4d3feb9b --- /dev/null +++ b/.github/workflows/release-sdkman.yml @@ -0,0 +1,69 @@ +################################################################################################### +### THIS IS A REUSABLE WORKFLOW TO PUBLISH SCALA TO SDKMAN! ### +### HOW TO USE: ### +### - THE RELEASE WORKFLOW SHOULD CALL THIS WORKFLOW ### +### - IT WILL PUBLISH TO SDKMAN! THE BINARIES TO EACH SUPPORTED PLATFORM AND A UNIVERSAL JAR ### +### - IT CHANGES THE DEFAULT VERSION IN SDKMAN! ### +### ### +### NOTE: ### +### - WE SHOULD KEEP IN SYNC THE NAME OF THE ARCHIVES WITH THE ACTUAL BUILD ### +### - WE SHOULD KEEP IN SYNC THE URL OF THE RELEASE ### +################################################################################################### + + +name: Release Scala to SDKMAN! +run-name: Release Scala ${{ inputs.version }} to SDKMAN! + +on: + workflow_call: + inputs: + version: + required: true + type: string + secrets: + CONSUMER-KEY: + required: true + CONSUMER-TOKEN: + required: true + +env: + RELEASE-URL: 'https://github.com/scala/scala3/releases/download/${{ inputs.version }}' + +jobs: + publish: + runs-on: ubuntu-latest + strategy: + matrix: + include: + - platform: LINUX_64 + archive : 'scala3-${{ inputs.version }}-x86_64-pc-linux.tar.gz' + - platform: LINUX_ARM64 + archive : 'scala3-${{ inputs.version }}-aarch64-pc-linux.tar.gz' + - platform: MAC_OSX + archive : 'scala3-${{ inputs.version }}-x86_64-apple-darwin.tar.gz' + - platform: MAC_ARM64 + archive : 'scala3-${{ inputs.version }}-aarch64-apple-darwin.tar.gz' + - platform: WINDOWS_64 + archive : 'scala3-${{ inputs.version }}-x86_64-pc-win32.tar.gz' + - platform: UNIVERSAL + archive : 'scala3-${{ inputs.version }}.zip' + steps: + - uses: hamzaremmal/sdkman-release-action@main # TODO: Make a release of the action and configure the version here + with: + CONSUMER-KEY : ${{ secrets.CONSUMER-KEY }} + CONSUMER-TOKEN : ${{ secrets.CONSUMER-TOKEN }} + CANDIDATE : scala + VERSION : ${{ inputs.version }} + URL : '${{ env.RELEASE-URL }}/${{ matrix.archive }}' + PLATFORM : ${{ matrix.platform }} + + default: + runs-on: ubuntu-latest + needs: publish + steps: + - uses: hamzaremmal/sdkman-default-action@main # TODO: Make a release of the action and configure the version here + with: + CONSUMER-KEY : ${{ secrets.CONSUMER-KEY }} + CONSUMER-TOKEN : ${{ secrets.CONSUMER-TOKEN }} + CANDIDATE : scala + VERSION : ${{ inputs.version }} From 857bf12e00aaca8cc337f94e83207001a884ca69 Mon Sep 17 00:00:00 2001 From: Hamza REMMAL Date: Sat, 8 Jun 2024 20:13:54 +0100 Subject: [PATCH 2/4] Amend the release workflow to use release-sdkman --- .github/workflows/releases.yml | 36 ++++----------- .github/workflows/scripts/publish-sdkman.sh | 50 --------------------- 2 files changed, 9 insertions(+), 77 deletions(-) delete mode 100755 .github/workflows/scripts/publish-sdkman.sh diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml index dde8b0372d52..fd883edd5a3d 100644 --- a/.github/workflows/releases.yml +++ b/.github/workflows/releases.yml @@ -2,31 +2,13 @@ name: Releases on: workflow_dispatch: -permissions: - contents: read - jobs: - publish_release: - runs-on: [self-hosted, Linux] - container: - image: lampepfl/dotty:2021-03-22 - options: --cpu-shares 4096 - - env: - SDKMAN_KEY: ${{ secrets.SDKMAN_KEY }} - SDKMAN_TOKEN: ${{ secrets.SDKMAN_TOKEN }} - - steps: - - name: Reset existing repo - run: | - git config --global --add safe.directory /__w/dotty/dotty - git -c "http.https://github.com/.extraheader=" fetch --recurse-submodules=no "https://github.com/lampepfl/dotty" && git reset --hard FETCH_HEAD || true - - - name: Cleanup - run: .github/workflows/cleanup.sh - - - name: Git Checkout - uses: actions/checkout@v4 - - - name: Publish to SDKMAN - run: .github/workflows/scripts/publish-sdkman.sh + publish-sdkman: + uses: ./.github/workflows/release-sdkman.yml + with: + version: '???' # TODO: Find a way to extract the version number. Easiest way would be to add it as an input + secrets: + CONSUMER-KEY: ${{ secrets.SDKMAN_KEY }} + CONSUMER-TOKEN: ${{ secrets.SDKMAN_TOKEN }} + + # TODO: ADD RELEASE WORKFLOW TO CHOCOLATEY AND OTHER PACKAGE MANAGERS HERE \ No newline at end of file diff --git a/.github/workflows/scripts/publish-sdkman.sh b/.github/workflows/scripts/publish-sdkman.sh deleted file mode 100755 index f959c426e9d8..000000000000 --- a/.github/workflows/scripts/publish-sdkman.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env bash - -# This is script for publishing scala on SDKMAN. -# Script resolves the latest stable version of scala and then send REST request to SDKMAN Vendor API. -# It's releasing and announcing the release of scala on SDKMAN. -# -# Requirement: -# - the latest stable version of scala should be available in github artifacts - -set -u - -# latest stable dotty version -DOTTY_VERSION=$(curl -s https://api.github.com/repos/scala/scala3/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') -DOTTY_URL="https://github.com/scala/scala3/releases/download/$DOTTY_VERSION/scala3-$DOTTY_VERSION.zip" - -# checking if dotty version is available -if ! curl --output /dev/null --silent --head --fail "$DOTTY_URL"; then - echo "URL doesn't exist: $DOTTY_URL" - exit 1 -fi - -# Release a new Candidate Version -curl --silent --show-error --fail \ - -X POST \ - -H "Consumer-Key: $SDKMAN_KEY" \ - -H "Consumer-Token: $SDKMAN_TOKEN" \ - -H "Content-Type: application/json" \ - -H "Accept: application/json" \ - -d '{"candidate": "scala", "version": "'"$DOTTY_VERSION"'", "url": "'"$DOTTY_URL"'"}' \ - https://vendors.sdkman.io/release - -if [[ $? -ne 0 ]]; then - echo "Fail sending POST request to releasing scala on SDKMAN." - exit 1 -fi - -# Set DOTTY_VERSION as Default for Candidate -curl --silent --show-error --fail \ - -X PUT \ - -H "Consumer-Key: $SDKMAN_KEY" \ - -H "Consumer-Token: $SDKMAN_TOKEN" \ - -H "Content-Type: application/json" \ - -H "Accept: application/json" \ - -d '{"candidate": "scala", "version": "'"$DOTTY_VERSION"'"}' \ - https://vendors.sdkman.io/default - -if [[ $? -ne 0 ]]; then - echo "Fail sending PUT request to announcing the release of scala on SDKMAN." - exit 1 -fi From 2a46134884b60b0e985f59b50240422e566dec1d Mon Sep 17 00:00:00 2001 From: Hamza REMMAL Date: Sat, 8 Jun 2024 20:48:33 +0100 Subject: [PATCH 3/4] Prepare the official release workflow --- ...{release-sdkman.yml => publish-sdkman.yml} | 4 +-- .github/workflows/releases.yml | 25 ++++++++++++++++--- 2 files changed, 24 insertions(+), 5 deletions(-) rename .github/workflows/{release-sdkman.yml => publish-sdkman.yml} (97%) diff --git a/.github/workflows/release-sdkman.yml b/.github/workflows/publish-sdkman.yml similarity index 97% rename from .github/workflows/release-sdkman.yml rename to .github/workflows/publish-sdkman.yml index 270b4d3feb9b..5d6744dd74e9 100644 --- a/.github/workflows/release-sdkman.yml +++ b/.github/workflows/publish-sdkman.yml @@ -11,8 +11,8 @@ ################################################################################################### -name: Release Scala to SDKMAN! -run-name: Release Scala ${{ inputs.version }} to SDKMAN! +name: Publish Scala to SDKMAN! +run-name: Publish Scala ${{ inputs.version }} to SDKMAN! on: workflow_call: diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml index fd883edd5a3d..4b75dd1b737d 100644 --- a/.github/workflows/releases.yml +++ b/.github/workflows/releases.yml @@ -1,12 +1,31 @@ -name: Releases +################################################################################################### +### OFFICIAL RELEASE WORKFLOW ### +### HOW TO USE: ### +### - THIS WORKFLOW WILL NEED TO BE TRIGGERED MANUALLY ### +### ### +### NOTE: ### +### - THIS WORKFLOW SHOULD ONLY BE RUN ON STABLE RELEASES ### +### - IT ASSUMES THAT THE PRE-RELEASE WORKFLOW WAS PREVIOUSLY EXECUTED ### +### ### +################################################################################################### + +name: Official release of Scala +run-name: Official release of Scala ${{ inputs.version }} + on: workflow_dispatch: + inputs: + version: + description: 'The version to officially release' + required: true + type: string jobs: + # TODO: ADD JOB TO SWITCH THE GITHUB RELEASE FROM DRAFT TO LATEST publish-sdkman: - uses: ./.github/workflows/release-sdkman.yml + uses: ./.github/workflows/publish-sdkman.yml with: - version: '???' # TODO: Find a way to extract the version number. Easiest way would be to add it as an input + version: ${{ inputs.version }} secrets: CONSUMER-KEY: ${{ secrets.SDKMAN_KEY }} CONSUMER-TOKEN: ${{ secrets.SDKMAN_TOKEN }} From 550a960305d771cdd0d4c3236284d20b73cad4ee Mon Sep 17 00:00:00 2001 From: Hamza Remmal Date: Fri, 14 Jun 2024 18:09:28 +0100 Subject: [PATCH 4/4] Use the commit instead of the branch --- .github/workflows/publish-sdkman.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-sdkman.yml b/.github/workflows/publish-sdkman.yml index 5d6744dd74e9..2126a3237d83 100644 --- a/.github/workflows/publish-sdkman.yml +++ b/.github/workflows/publish-sdkman.yml @@ -48,7 +48,7 @@ jobs: - platform: UNIVERSAL archive : 'scala3-${{ inputs.version }}.zip' steps: - - uses: hamzaremmal/sdkman-release-action@main # TODO: Make a release of the action and configure the version here + - uses: hamzaremmal/sdkman-release-action@7e437233a6bd79bc4cb0fa9071b685e94bdfdba6 with: CONSUMER-KEY : ${{ secrets.CONSUMER-KEY }} CONSUMER-TOKEN : ${{ secrets.CONSUMER-TOKEN }} @@ -61,7 +61,7 @@ jobs: runs-on: ubuntu-latest needs: publish steps: - - uses: hamzaremmal/sdkman-default-action@main # TODO: Make a release of the action and configure the version here + - uses: hamzaremmal/sdkman-default-action@866bc79fc5bd397eeb48f9cedda2f15221c8515d with: CONSUMER-KEY : ${{ secrets.CONSUMER-KEY }} CONSUMER-TOKEN : ${{ secrets.CONSUMER-TOKEN }}