Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add github action to release packages #78

Merged
merged 11 commits into from
Dec 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 70 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,85 @@
name: Publish package to GitHub Packages
on:
release:
types: [created]
schedule:
- cron: '0 10 * * *'
workflow_dispatch:
inputs:
mode:
description: 'staging/snapshot, default is snapshot'
required: true
default: 'snapshot'


jobs:
publish:
check_date:
runs-on: ubuntu-latest
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 }}
permissions:
contents: read
packages: write
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)
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 -Pversion=$VERSION
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: publish to github package repository (Linux)
if: runner.os == 'Linux'
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
14 changes: 2 additions & 12 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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()
}
Expand Down Expand Up @@ -77,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")
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
kotlin.code.style=official
group=org.pastalab.fray
version=0.1.6-SNAPSHOT
Loading