From 2534fa5aab5f9a646204370ffd194eb6131028b1 Mon Sep 17 00:00:00 2001 From: Cleo Schneider Date: Thu, 12 Oct 2023 14:10:07 -0400 Subject: [PATCH] Replace hub with GitHub CLI 'gh' for GitHub Actions --- .github/workflows/release.yml | 19 ++++++---------- docs/release_process.md | 2 +- .../scripts/ops/github/DeleteOldRelease.kt | 2 +- .../flank/scripts/ops/github/ReleaseFlank.kt | 22 +++++++++---------- 4 files changed, 20 insertions(+), 25 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 276d670691..b9e45609aa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -69,20 +69,11 @@ jobs: with: arguments: "clean test_runner:build test_runner:shadowJar" - - name: Authenticate to hub - run: | - mkdir -p ~/.config/ - - cat << EOF > ~/.config/hub - github.com: - - user: $GITHUB_ACTOR - oauth_token: ${{ secrets.GITHUB_TOKEN }} - protocol: https - EOF - - name: Delete old release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - hub version + gh --version flankScripts github delete_release --git-tag=$RELEASE_TAG - name: Delete old tag @@ -91,10 +82,14 @@ jobs: - name: Release snapshot if: ${{ env.RELEASE_TAG == 'flank-snapshot' }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: flankScripts github make_release --input-file=./test_runner/build/libs/flank.jar --git-tag=$RELEASE_TAG --commit-hash=$GIT_SHORT_HASH --snapshot - name: Release stable if: startsWith(github.ref, 'refs/tags/v') + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: flankScripts github make_release --input-file=./test_runner/build/libs/flank.jar --git-tag=$RELEASE_TAG --token=${{ secrets.GITHUB_TOKEN }} - name: Append checksum to release diff --git a/docs/release_process.md b/docs/release_process.md index 08bb6fcf61..900a9595bf 100644 --- a/docs/release_process.md +++ b/docs/release_process.md @@ -5,7 +5,7 @@ 1. A release process should be run withing macOS environment 2. The machine should contain: `homebrew` - Package manager - `hub` - Github CLI tool + `gh` - Github CLI tool ## Current setup diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ops/github/DeleteOldRelease.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/github/DeleteOldRelease.kt index 19b6c55836..927896a9f1 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/ops/github/DeleteOldRelease.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/github/DeleteOldRelease.kt @@ -4,4 +4,4 @@ import flank.scripts.utils.runCommand fun deleteOldRelease(tag: String) = "$DELETE_RELEASE_COMMAND $tag".runCommand() -private const val DELETE_RELEASE_COMMAND = "hub release delete" +private const val DELETE_RELEASE_COMMAND = "gh release delete" diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ops/github/ReleaseFlank.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/github/ReleaseFlank.kt index 0298cb8cf6..f6921ba983 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/ops/github/ReleaseFlank.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/github/ReleaseFlank.kt @@ -41,23 +41,23 @@ private fun moveFlankToReleaseDirectory(inputPath: Path) = if (inputPath.toFile().renameTo(File(RELEASE_DIRECTORY))) RELEASE_DIRECTORY else inputPath.toAbsolutePath() .toString() +/** + * See more details: https://cli.github.com/manual/gh_release_create + */ private fun hubStableSnapshotCommand(path: String, gitTag: String, commitHash: String) = listOf( - "hub", "release", "create", - "-p", - "-a", path, - "-m", "Flank $gitTag", - "-m", "Snapshot release for commit $commitHash", - gitTag + "gh", "release", "create", gitTag, path, + "-p", // create a prerelease + "-t", "Flank $gitTag", + "-n", "Snapshot release for commit $commitHash", + ) private fun hubStableReleaseCommand(path: String, gitTag: String, token: String) = listOf( - "hub", "release", "create", - "-a", path, - "-m", "Flank $gitTag", - "-m", generateReleaseNotes(token).asString(gitTag), - gitTag + "gh", "release", "create", gitTag, path, + "-t", "Flank $gitTag", + "-n", generateReleaseNotes(token).asString(gitTag), ) private const val RELEASE_DIRECTORY = "./RELEASE/flank.jar"