From 83b580b4b425baeacc6e84e025c50a267f3c21af Mon Sep 17 00:00:00 2001 From: Wojciech Mazur Date: Mon, 9 Dec 2024 17:48:03 +0100 Subject: [PATCH 1/4] Replace deprecated `actions/create-release` and `actions/upload-release-asset` with `gh release create` command --- .github/workflows/ci.yaml | 316 ++------------------------------------ 1 file changed, 13 insertions(+), 303 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a2006e16c7e8..b77a64f1a54b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -838,309 +838,19 @@ jobs: # Create the GitHub release - name: Create GitHub Release - id: create_gh_release - uses: actions/create-release@latest - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token - with: - tag_name: ${{ github.ref }} - release_name: ${{ github.ref }} - body_path: ./changelogs/${{ env.RELEASE_TAG }}.md - draft: true - prerelease: ${{ contains(env.RELEASE_TAG, '-') }} - - # The following upload steps are generated using template: - # val baseFileName = "scala3-${{ env.RELEASE_TAG }}" - # def upload(kind: String, path: String, contentType: String, distribution: String) = - # s"""- name: Upload $kind to GitHub Release ($distribution) - # uses: actions/upload-release-asset@v1 - # env: - # GITHUB_TOKEN: $${{ secrets.GITHUB_TOKEN }} - # with: - # upload_url: $${{ steps.create_gh_release.outputs.upload_url }} - # asset_path: ./${path} - # asset_name: ${path} - # asset_content_type: ${contentType}""" - # def uploadSDK(distribution: String, suffix: String) = - # val filename = s"${baseFileName}${suffix}" - # s""" - # # $distribution - # ${upload("zip archive", s"$filename.zip", "application/zip", distribution)} - # ${upload("zip archive SHA", s"$filename.zip.sha256", "text/plain", distribution)} - # ${upload("tar.gz archive", s"$filename.tar.gz", "application/gzip", distribution)} - # ${upload("tar.gz archive SHA", s"$filename.tar.gz.sha256", "text/plain", distribution)} - # """ - # def uploadMSI() = - # val distribution = "Windows x86_64 MSI" - # s""" - # # $distribution - # ${upload(".msi file", s"${baseFileName}.msi", "application/x-msi", distribution)} - # ${upload(".msi file SHA", s"${baseFileName}.msi.sha256", "text/plain", distribution)} - # """ - # @main def gen = - # Seq( - # uploadSDK("Universal", ""), - # uploadSDK("Linux x86-64", "-x86_64-pc-linux"), - # uploadSDK("Linux aarch64", "-aarch64-pc-linux"), - # uploadSDK("Mac x86-64", "-x86_64-apple-darwin"), - # uploadSDK("Mac aarch64", "-aarch64-apple-darwin"), - # uploadSDK("Windows x86_64", "-x86_64-pc-win32"), - # uploadMSI() - # ).foreach(println) - - # Universal - - name: Upload zip archive to GitHub Release (Universal) - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_gh_release.outputs.upload_url }} - asset_path: ./scala3-${{ env.RELEASE_TAG }}.zip - asset_name: scala3-${{ env.RELEASE_TAG }}.zip - asset_content_type: application/zip - - name: Upload zip archive SHA to GitHub Release (Universal) - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_gh_release.outputs.upload_url }} - asset_path: ./scala3-${{ env.RELEASE_TAG }}.zip.sha256 - asset_name: scala3-${{ env.RELEASE_TAG }}.zip.sha256 - asset_content_type: text/plain - - name: Upload tar.gz archive to GitHub Release (Universal) - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_gh_release.outputs.upload_url }} - asset_path: ./scala3-${{ env.RELEASE_TAG }}.tar.gz - asset_name: scala3-${{ env.RELEASE_TAG }}.tar.gz - asset_content_type: application/gzip - - name: Upload tar.gz archive SHA to GitHub Release (Universal) - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_gh_release.outputs.upload_url }} - asset_path: ./scala3-${{ env.RELEASE_TAG }}.tar.gz.sha256 - asset_name: scala3-${{ env.RELEASE_TAG }}.tar.gz.sha256 - asset_content_type: text/plain - - - # Linux x86-64 - - name: Upload zip archive to GitHub Release (Linux x86-64) - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_gh_release.outputs.upload_url }} - asset_path: ./scala3-${{ env.RELEASE_TAG }}-x86_64-pc-linux.zip - asset_name: scala3-${{ env.RELEASE_TAG }}-x86_64-pc-linux.zip - asset_content_type: application/zip - - name: Upload zip archive SHA to GitHub Release (Linux x86-64) - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_gh_release.outputs.upload_url }} - asset_path: ./scala3-${{ env.RELEASE_TAG }}-x86_64-pc-linux.zip.sha256 - asset_name: scala3-${{ env.RELEASE_TAG }}-x86_64-pc-linux.zip.sha256 - asset_content_type: text/plain - - name: Upload tar.gz archive to GitHub Release (Linux x86-64) - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_gh_release.outputs.upload_url }} - asset_path: ./scala3-${{ env.RELEASE_TAG }}-x86_64-pc-linux.tar.gz - asset_name: scala3-${{ env.RELEASE_TAG }}-x86_64-pc-linux.tar.gz - asset_content_type: application/gzip - - name: Upload tar.gz archive SHA to GitHub Release (Linux x86-64) - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_gh_release.outputs.upload_url }} - asset_path: ./scala3-${{ env.RELEASE_TAG }}-x86_64-pc-linux.tar.gz.sha256 - asset_name: scala3-${{ env.RELEASE_TAG }}-x86_64-pc-linux.tar.gz.sha256 - asset_content_type: text/plain - - - # Linux aarch64 - - name: Upload zip archive to GitHub Release (Linux aarch64) - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_gh_release.outputs.upload_url }} - asset_path: ./scala3-${{ env.RELEASE_TAG }}-aarch64-pc-linux.zip - asset_name: scala3-${{ env.RELEASE_TAG }}-aarch64-pc-linux.zip - asset_content_type: application/zip - - name: Upload zip archive SHA to GitHub Release (Linux aarch64) - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_gh_release.outputs.upload_url }} - asset_path: ./scala3-${{ env.RELEASE_TAG }}-aarch64-pc-linux.zip.sha256 - asset_name: scala3-${{ env.RELEASE_TAG }}-aarch64-pc-linux.zip.sha256 - asset_content_type: text/plain - - name: Upload tar.gz archive to GitHub Release (Linux aarch64) - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_gh_release.outputs.upload_url }} - asset_path: ./scala3-${{ env.RELEASE_TAG }}-aarch64-pc-linux.tar.gz - asset_name: scala3-${{ env.RELEASE_TAG }}-aarch64-pc-linux.tar.gz - asset_content_type: application/gzip - - name: Upload tar.gz archive SHA to GitHub Release (Linux aarch64) - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_gh_release.outputs.upload_url }} - asset_path: ./scala3-${{ env.RELEASE_TAG }}-aarch64-pc-linux.tar.gz.sha256 - asset_name: scala3-${{ env.RELEASE_TAG }}-aarch64-pc-linux.tar.gz.sha256 - asset_content_type: text/plain - - - # Mac x86-64 - - name: Upload zip archive to GitHub Release (Mac x86-64) - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_gh_release.outputs.upload_url }} - asset_path: ./scala3-${{ env.RELEASE_TAG }}-x86_64-apple-darwin.zip - asset_name: scala3-${{ env.RELEASE_TAG }}-x86_64-apple-darwin.zip - asset_content_type: application/zip - - name: Upload zip archive SHA to GitHub Release (Mac x86-64) - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_gh_release.outputs.upload_url }} - asset_path: ./scala3-${{ env.RELEASE_TAG }}-x86_64-apple-darwin.zip.sha256 - asset_name: scala3-${{ env.RELEASE_TAG }}-x86_64-apple-darwin.zip.sha256 - asset_content_type: text/plain - - name: Upload tar.gz archive to GitHub Release (Mac x86-64) - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_gh_release.outputs.upload_url }} - asset_path: ./scala3-${{ env.RELEASE_TAG }}-x86_64-apple-darwin.tar.gz - asset_name: scala3-${{ env.RELEASE_TAG }}-x86_64-apple-darwin.tar.gz - asset_content_type: application/gzip - - name: Upload tar.gz archive SHA to GitHub Release (Mac x86-64) - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_gh_release.outputs.upload_url }} - asset_path: ./scala3-${{ env.RELEASE_TAG }}-x86_64-apple-darwin.tar.gz.sha256 - asset_name: scala3-${{ env.RELEASE_TAG }}-x86_64-apple-darwin.tar.gz.sha256 - asset_content_type: text/plain - - - # Mac aarch64 - - name: Upload zip archive to GitHub Release (Mac aarch64) - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_gh_release.outputs.upload_url }} - asset_path: ./scala3-${{ env.RELEASE_TAG }}-aarch64-apple-darwin.zip - asset_name: scala3-${{ env.RELEASE_TAG }}-aarch64-apple-darwin.zip - asset_content_type: application/zip - - name: Upload zip archive SHA to GitHub Release (Mac aarch64) - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_gh_release.outputs.upload_url }} - asset_path: ./scala3-${{ env.RELEASE_TAG }}-aarch64-apple-darwin.zip.sha256 - asset_name: scala3-${{ env.RELEASE_TAG }}-aarch64-apple-darwin.zip.sha256 - asset_content_type: text/plain - - name: Upload tar.gz archive to GitHub Release (Mac aarch64) - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_gh_release.outputs.upload_url }} - asset_path: ./scala3-${{ env.RELEASE_TAG }}-aarch64-apple-darwin.tar.gz - asset_name: scala3-${{ env.RELEASE_TAG }}-aarch64-apple-darwin.tar.gz - asset_content_type: application/gzip - - name: Upload tar.gz archive SHA to GitHub Release (Mac aarch64) - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_gh_release.outputs.upload_url }} - asset_path: ./scala3-${{ env.RELEASE_TAG }}-aarch64-apple-darwin.tar.gz.sha256 - asset_name: scala3-${{ env.RELEASE_TAG }}-aarch64-apple-darwin.tar.gz.sha256 - asset_content_type: text/plain - - - # Windows x86_64 - - name: Upload zip archive to GitHub Release (Windows x86_64) - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_gh_release.outputs.upload_url }} - asset_path: ./scala3-${{ env.RELEASE_TAG }}-x86_64-pc-win32.zip - asset_name: scala3-${{ env.RELEASE_TAG }}-x86_64-pc-win32.zip - asset_content_type: application/zip - - name: Upload zip archive SHA to GitHub Release (Windows x86_64) - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_gh_release.outputs.upload_url }} - asset_path: ./scala3-${{ env.RELEASE_TAG }}-x86_64-pc-win32.zip.sha256 - asset_name: scala3-${{ env.RELEASE_TAG }}-x86_64-pc-win32.zip.sha256 - asset_content_type: text/plain - - name: Upload tar.gz archive to GitHub Release (Windows x86_64) - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_gh_release.outputs.upload_url }} - asset_path: ./scala3-${{ env.RELEASE_TAG }}-x86_64-pc-win32.tar.gz - asset_name: scala3-${{ env.RELEASE_TAG }}-x86_64-pc-win32.tar.gz - asset_content_type: application/gzip - - name: Upload tar.gz archive SHA to GitHub Release (Windows x86_64) - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_gh_release.outputs.upload_url }} - asset_path: ./scala3-${{ env.RELEASE_TAG }}-x86_64-pc-win32.tar.gz.sha256 - asset_name: scala3-${{ env.RELEASE_TAG }}-x86_64-pc-win32.tar.gz.sha256 - asset_content_type: text/plain - - - # Windows x86_64 MSI - - name: Upload .msi file to GitHub Release (Windows x86_64 MSI) - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_gh_release.outputs.upload_url }} - asset_path: ./scala3-${{ env.RELEASE_TAG }}.msi - asset_name: scala3-${{ env.RELEASE_TAG }}.msi - asset_content_type: application/x-msi - - name: Upload .msi file SHA to GitHub Release (Windows x86_64 MSI) - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_gh_release.outputs.upload_url }} - asset_path: ./scala3-${{ env.RELEASE_TAG }}.msi.sha256 - asset_name: scala3-${{ env.RELEASE_TAG }}.msi.sha256 - asset_content_type: text/plain + shell: bash + run: | + gh release create \ + --draft \ + --title "${{ env.RELEASE_TAG }}" \ + --notes-file ./changelogs/${{ env.RELEASE_TAG }}.md \ + --latest=${{ !contains(env.RELEASE_TAG, '-RC') }} \ + --prerelease=${{ contains(env.RELEASE_TAG, '-RC') }} \ + --verify-tag ${{ env.RELEASE_TAG }} \ + scala3-${{ env.RELEASE_TAG }}*.zip \ + scala3-${{ env.RELEASE_TAG }}*.tar.gz \ + scala3-${{ env.RELEASE_TAG }}*.sha256 \ + scala3-${{ env.RELEASE_TAG }}.msi - name: Publish Release run: ./project/scripts/sbtPublish ";project scala3-bootstrapped ;publishSigned ;sonatypeBundleUpload" From eb82f53c1f778de72598c47feeaee3856326b649 Mon Sep 17 00:00:00 2001 From: Wojciech Mazur Date: Mon, 9 Dec 2024 18:42:34 +0100 Subject: [PATCH 2/4] Restore GITHUB_TOKEN env variable --- .github/workflows/ci.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b77a64f1a54b..b3292485efc6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -838,6 +838,8 @@ jobs: # Create the GitHub release - name: Create GitHub Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token shell: bash run: | gh release create \ From d6288f4beb33a769124a291e36c828499ef49088 Mon Sep 17 00:00:00 2001 From: Wojciech Mazur Date: Tue, 10 Dec 2024 11:13:49 +0100 Subject: [PATCH 3/4] Install GH CLI (missing on lampepfl/dotty image) --- .github/workflows/ci.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b3292485efc6..38395728a3ea 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -736,7 +736,7 @@ jobs: publish_release: permissions: - contents: write # for actions/create-release to create a release + contents: write # for GH CLI to create a release runs-on: [self-hosted, Linux] container: image: lampepfl/dotty:2024-10-18 @@ -778,6 +778,7 @@ jobs: - name: Add SBT proxy repositories run: cp -vf .github/workflows/repositories /root/.sbt/ ; true + # Extract the release tag - name: Extract the release tag run : echo "RELEASE_TAG=${GITHUB_REF#*refs/tags/}" >> $GITHUB_ENV @@ -836,6 +837,11 @@ jobs: mv scala.msi "${msiInstaller}" sha256sum "${msiInstaller}" > "${msiInstaller}.sha256" + - name: Install GH CLI + uses: dev-hanz-ops/install-gh-cli-action@v0.2.0 + with: + gh-cli-version: 2.59.0 + # Create the GitHub release - name: Create GitHub Release env: From e35924fcfb09630f366b0228f2532f0a7a436ef0 Mon Sep 17 00:00:00 2001 From: Wojciech Mazur Date: Wed, 11 Dec 2024 00:11:32 +0100 Subject: [PATCH 4/4] Add git config before usage of gh release --- .github/workflows/ci.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 38395728a3ea..765a65d46855 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -848,6 +848,9 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token shell: bash run: | + # We need to config safe.directory in every step that might reference git + # It is not persisted between steps + git config --global --add safe.directory /__w/scala3/scala3 gh release create \ --draft \ --title "${{ env.RELEASE_TAG }}" \