From 2a5056104be027e179b2ef51f725fcb63a0fef40 Mon Sep 17 00:00:00 2001 From: Ao Li Date: Sun, 22 Dec 2024 11:16:06 -0500 Subject: [PATCH 01/11] Add github release action. --- .github/workflows/release.yml | 63 +++++++++++++++++++++++++++-------- build.gradle.kts | 10 ------ gradle.properties | 2 ++ 3 files changed, 52 insertions(+), 23 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cc44196b..dbcd76fa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,24 +1,61 @@ name: Publish package to GitHub Packages on: - release: - types: [created] - workflow_dispatch: + schedule: + - cron: '0 10 * * *' + jobs: - publish: + check_date: runs-on: ubuntu-latest - permissions: - contents: read - packages: write + name: Check latest commit + outputs: + should_run: ${{ steps.should_run.outputs.should_run }} + steps: + - uses: actions/checkout@v2 + - name: print latest_commit + run: echo ${{ github.sha }} + + - id: should_run + continue-on-error: true + name: check latest commit is less than a day + if: ${{ github.event_name == 'schedule' }} + run: test -z $(git rev-list --after="24 hours" ${{ github.sha }}) && echo "::set-output name=should_run::false" + publish: + needs: check_date + if: github.repository == 'cmu-pasta/fray' && needs.check_date.outputs.should_run != 'false' + runs-on: ${{ matrix.operating-system }} + strategy: + fail-fast: false + matrix: + operating-system: [ macos-latest, ubuntu-latest] steps: - uses: actions/checkout@v4 - uses: actions/setup-java@v4 with: + distribution: 'temurin' java-version: '21' - distribution: 'corretto' - - name: Setup Gradle - uses: gradle/actions/setup-gradle@dbbdc275be76ac10734476cc723d82dfe7ec6eda # v3.4.2 - - - name: Publish package - run: ./gradlew publish + cache: 'gradle' + - uses: actions/cache@v4 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('*/build.gradle.kts', 'engines/**/build.gradle.kts', 'extensions/**/build.gradle.kts') }} + restore-keys: | + ${{ runner.os }}-gradle- + - name: Read and update version + run: | + BASE_VERSION=$(grep "^version=" gradle.properties | cut -d'=' -f2) + TIMESTAMP=$(date +"%Y%m%d-%H%M") + NIGHTLY_VERSION="${BASE_VERSION}-nightly-${TIMESTAMP}" + echo "VERSION=${NIGHTLY_VERSION}" >> $GITHUB_ENV + echo "Nightly version: $NIGHTLY_VERSION" + - name: build the repository + run: ./gradlew build + - name: publish to github package repository + if: runner.os == 'macOS' + run: ./gradlew :jvmti:publish -Pversion=$VERSION + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: publish to github package repository + if: runner.os == 'Linux' + run: ./gradlew -Pversion=$VERSION env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/build.gradle.kts b/build.gradle.kts index 1d5d2a67..f4c00882 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,8 +1,4 @@ -import groovy.namespace.QName -import groovy.util.Node -import groovy.util.NodeList import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform -import java.util.regex.Pattern plugins { kotlin("jvm") version "2.0.0" @@ -11,12 +7,6 @@ plugins { id("org.jetbrains.dokka") version "1.9.20" } - -allprojects { - group = "org.pastalab.fray" - version = "0.1.6-SNAPSHOT" -} - repositories { mavenCentral() } diff --git a/gradle.properties b/gradle.properties index 7fc6f1ff..0cb97252 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1,3 @@ kotlin.code.style=official +group = org.pastalab.fray +version = 0.1.6-SNAPSHOT From ea2bbf7efdee4ebae9b7c2341a7f14691aec26b4 Mon Sep 17 00:00:00 2001 From: Ao Li Date: Sun, 22 Dec 2024 11:18:59 -0500 Subject: [PATCH 02/11] add workflow_dispatch trigger --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dbcd76fa..ff4ef46c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,6 +2,7 @@ name: Publish package to GitHub Packages on: schedule: - cron: '0 10 * * *' + workflow_dispatch: jobs: check_date: From f40b53c792fa8245e28a09fc707d2456ce873bc3 Mon Sep 17 00:00:00 2001 From: Ao Li Date: Sun, 22 Dec 2024 11:23:40 -0500 Subject: [PATCH 03/11] Fix publish configuration. --- build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index f4c00882..69b1f902 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -67,8 +67,8 @@ configure(allprojects - rootProject - project(":instrumentation")) { name = "GitHubPackages" url = uri("https://maven.pkg.github.com/cmu-pasta/fray") credentials { - username = project.findProperty("gpr.user") as String? ?: System.getenv("USERNAME") - password = project.findProperty("gpr.key") as String? ?: System.getenv("TOKEN") + username = project.findProperty("gpr.user") as String? ?: System.getenv("GITHUB_ACTOR") + password = project.findProperty("gpr.key") as String? ?: System.getenv("GITHUB_TOKEN") } } } From 361572f9d7eebc7cbc0cee6f478f1d5e698f02b0 Mon Sep 17 00:00:00 2001 From: Ao Li Date: Sun, 22 Dec 2024 11:28:34 -0500 Subject: [PATCH 04/11] Also add release option. --- .github/workflows/release.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ff4ef46c..ca3150d2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -60,3 +60,19 @@ jobs: run: ./gradlew -Pversion=$VERSION env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + release: + needs: publish + runs-on: ubuntu-latest + steps: + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ env.VERSION }} + release_name: "Release ${{ env.VERSION }}" + body: | + This release includes the following: + - Version: `${{ env.VERSION }}` + - Published packages are available in [GitHub Packages](https://github.com/orgs/cmu-pasta/packages?repo_name=fray). + draft: false + prerelease: true From b6748586b84063fbfe121bc4bef2e84e8cc714b2 Mon Sep 17 00:00:00 2001 From: Ao Li Date: Sun, 22 Dec 2024 11:29:31 -0500 Subject: [PATCH 05/11] Fix linux publish command. --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ca3150d2..40482c74 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -57,7 +57,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: publish to github package repository if: runner.os == 'Linux' - run: ./gradlew -Pversion=$VERSION + run: ./gradlew publish -Pversion=$VERSION env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} release: From 7d1fb3381bc0a923e27f3a96000c37a69937c7a6 Mon Sep 17 00:00:00 2001 From: Ao Li Date: Sun, 22 Dec 2024 11:30:26 -0500 Subject: [PATCH 06/11] Fix action file. --- .github/workflows/release.yml | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 40482c74..17c0f3f9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -60,19 +60,19 @@ jobs: run: ./gradlew publish -Pversion=$VERSION env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - release: - needs: publish - runs-on: ubuntu-latest - steps: - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ env.VERSION }} - release_name: "Release ${{ env.VERSION }}" - body: | - This release includes the following: - - Version: `${{ env.VERSION }}` - - Published packages are available in [GitHub Packages](https://github.com/orgs/cmu-pasta/packages?repo_name=fray). - draft: false - prerelease: true + release: + needs: publish + runs-on: ubuntu-latest + steps: + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ env.VERSION }} + release_name: "Release ${{ env.VERSION }}" + body: | + This release includes the following: + - Version: `${{ env.VERSION }}` + - Published packages are available in [GitHub Packages](https://github.com/orgs/cmu-pasta/packages?repo_name=fray). + draft: false + prerelease: true From 333c74198e354f791348913f6ba646d064d5b951 Mon Sep 17 00:00:00 2001 From: Ao Li Date: Sun, 22 Dec 2024 11:33:25 -0500 Subject: [PATCH 07/11] Fix action file. --- .github/workflows/release.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 17c0f3f9..94b78a71 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -64,15 +64,15 @@ jobs: needs: publish runs-on: ubuntu-latest steps: - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ env.VERSION }} - release_name: "Release ${{ env.VERSION }}" - body: | - This release includes the following: - - Version: `${{ env.VERSION }}` - - Published packages are available in [GitHub Packages](https://github.com/orgs/cmu-pasta/packages?repo_name=fray). - draft: false - prerelease: true + - uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ env.VERSION }} + release_name: "Release ${{ env.VERSION }}" + body: | + This release includes the following: + - Version: `${{ env.VERSION }}` + - Published packages are available in [GitHub Packages](https://github.com/orgs/cmu-pasta/packages?repo_name=fray). + draft: false + prerelease: true From 81aca9e72c5454e16b1a10c8e9c3580bcbb7809d Mon Sep 17 00:00:00 2001 From: Ao Li Date: Sun, 22 Dec 2024 11:38:23 -0500 Subject: [PATCH 08/11] Fix gradle properties. --- .github/workflows/release.yml | 4 ++-- gradle.properties | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 94b78a71..94d4a4e1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -50,12 +50,12 @@ jobs: echo "Nightly version: $NIGHTLY_VERSION" - name: build the repository run: ./gradlew build - - name: publish to github package repository + - name: publish to github package repository (macOS) if: runner.os == 'macOS' run: ./gradlew :jvmti:publish -Pversion=$VERSION env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: publish to github package repository + - name: publish to github package repository (Linux) if: runner.os == 'Linux' run: ./gradlew publish -Pversion=$VERSION env: diff --git a/gradle.properties b/gradle.properties index 0cb97252..a42020ed 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ kotlin.code.style=official -group = org.pastalab.fray -version = 0.1.6-SNAPSHOT +group=org.pastalab.fray +version=0.1.6-SNAPSHOT From d28a8c301b8c4aa24d9adc80e9ce4c8547706910 Mon Sep 17 00:00:00 2001 From: Ao Li Date: Sun, 22 Dec 2024 11:45:46 -0500 Subject: [PATCH 09/11] Allow package write. --- .github/workflows/release.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 94d4a4e1..64925efc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,6 +24,9 @@ jobs: needs: check_date if: github.repository == 'cmu-pasta/fray' && needs.check_date.outputs.should_run != 'false' runs-on: ${{ matrix.operating-system }} + permissions: + contents: read + packages: write strategy: fail-fast: false matrix: @@ -52,12 +55,12 @@ jobs: run: ./gradlew build - name: publish to github package repository (macOS) if: runner.os == 'macOS' - run: ./gradlew :jvmti:publish -Pversion=$VERSION + run: ./gradlew :jvmti:publish env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: publish to github package repository (Linux) if: runner.os == 'Linux' - run: ./gradlew publish -Pversion=$VERSION + run: ./gradlew publish env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} release: From 321fc7e92bc9fb92314a8c125ac6bb067775ea40 Mon Sep 17 00:00:00 2001 From: Ao Li Date: Sun, 22 Dec 2024 11:55:22 -0500 Subject: [PATCH 10/11] Do not create GH release --- .github/workflows/release.yml | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 64925efc..46da903c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -63,19 +63,3 @@ jobs: run: ./gradlew publish env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - release: - needs: publish - runs-on: ubuntu-latest - steps: - - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ env.VERSION }} - release_name: "Release ${{ env.VERSION }}" - body: | - This release includes the following: - - Version: `${{ env.VERSION }}` - - Published packages are available in [GitHub Packages](https://github.com/orgs/cmu-pasta/packages?repo_name=fray). - draft: false - prerelease: true From 04e7b74f6b86027c7d6b6e0e448c10d49f28969b Mon Sep 17 00:00:00 2001 From: Ao Li Date: Sun, 22 Dec 2024 12:04:01 -0500 Subject: [PATCH 11/11] Add release option. --- .github/workflows/release.yml | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 46da903c..425a0ee6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,6 +3,12 @@ on: schedule: - cron: '0 10 * * *' workflow_dispatch: + inputs: + mode: + description: 'staging/snapshot, default is snapshot' + required: true + default: 'snapshot' + jobs: check_date: @@ -47,19 +53,33 @@ jobs: - name: Read and update version run: | BASE_VERSION=$(grep "^version=" gradle.properties | cut -d'=' -f2) - TIMESTAMP=$(date +"%Y%m%d-%H%M") - NIGHTLY_VERSION="${BASE_VERSION}-nightly-${TIMESTAMP}" - echo "VERSION=${NIGHTLY_VERSION}" >> $GITHUB_ENV - echo "Nightly version: $NIGHTLY_VERSION" + if [[ "${{ github.event.inputs.mode }}" == "staging" ]]; then + BASE_VERSION=${BASE_VERSION/-SNAPSHOT/} + fi + echo "VERSION=${BASE_VERSION}" >> $GITHUB_ENV + echo "Version: $BASE_VERSION" - name: build the repository run: ./gradlew build - name: publish to github package repository (macOS) if: runner.os == 'macOS' - run: ./gradlew :jvmti:publish + run: ./gradlew :jvmti:publish -Pversion=$VERSION env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: publish to github package repository (Linux) if: runner.os == 'Linux' - run: ./gradlew publish + run: ./gradlew publish -Pversion=$VERSION env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/create-release@v1 + if: runner.os == 'Linux' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ env.VERSION }} + release_name: "Release ${{ env.VERSION }}" + body: | + This release includes the following: + - Version: `${{ env.VERSION }}` + - Published packages are available in [GitHub Packages](https://github.com/orgs/cmu-pasta/packages?repo_name=fray). + draft: false + prerelease: true