Skip to content

Commit

Permalink
chore: Setup publishing on release creation (#12)
Browse files Browse the repository at this point in the history
This sets up publishing of releases when a release is created in github.
Most of this was cribbed from
https://github.com/Faire/faire-detekt-rules/blob/cb7c9d831c3b93de49db75c8bc8fd4f95192ed03/.github/workflows/release.yml\#L14
and updated for this repo's use-case.
  • Loading branch information
Nava2 authored Aug 16, 2024
1 parent b32b937 commit d9bf077
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/release-snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Trigger Snapshot Release

on:
push:
branches:
- main

jobs:
publish_archives:
runs-on: ubuntu-latest

permissions:
contents: read

steps:
- name: Checkout the repo
uses: actions/checkout@v4

- name: Setup gradle
uses: gradle/actions/setup-gradle@v4
with:
gradle-home-cache-cleanup: true

- name: Verify build
run: ./gradlew check

- name: Publish the artifacts
run: ./gradlew publishPlugins --no-configuration-cache
env:
GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }}
GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }}
34 changes: 34 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Trigger Release

on:
workflow_dispatch:
release:
types: [published]

jobs:
publish_archives:
runs-on: ubuntu-latest

permissions:
contents: read

env:
RELEASE: true

steps:
- name: Checkout the repo
uses: actions/checkout@v4

- name: Setup gradle
uses: gradle/actions/setup-gradle@v4
with:
gradle-home-cache-cleanup: true

- name: Verify build
run: ./gradlew check

- name: Publish the artifacts
run: ./gradlew publishPlugins --no-configuration-cache
env:
GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }}
GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }}
17 changes: 17 additions & 0 deletions build-targets-gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,23 @@ plugins {
group = "com.faire.gradle"
version = "0.0.0"

if (!providers.environmentVariable("RELEASE").isPresent) {
val gitSha = providers.environmentVariable("GITHUB_SHA")
.orElse(
provider {
// nest the provider, we don't want to invalidate the config cache for this
providers.exec { commandLine("git", "rev-parse", "--short", "HEAD") }
.standardOutput
.asText
.map { it.trim() }
.get()
},
)
.get()

version = "$version-$gitSha-SNAPSHOT"
}

dependencies {
api(kotlin("stdlib"))

Expand Down

0 comments on commit d9bf077

Please sign in to comment.