Skip to content

Commit

Permalink
Update workflows to publish snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
kaikreuzer committed Jan 2, 2025
1 parent d22b6e9 commit 07d136e
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 115 deletions.
116 changes: 25 additions & 91 deletions .github/workflows/gradle-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,110 +2,44 @@
#
# SPDX-License-Identifier: Apache-2.0

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle

name: Gradle Package
name: Publish

on:
push:
tags: [ 'releasemain' ]
tags: [ main ]

jobs:
build:
name: "Publish"
verify:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write

steps:
- name: Get Token
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.LMOS_COMMITER_APPID }}
private-key: ${{ secrets.LMOS_COMMITER }}

- name: Checkout main
uses: actions/checkout@v4
with:
ref: 'main'
fetch-depth: '0'
token: ${{ steps.app-token.outputs.token }}

- name: Drop release tag
run: git push origin :releasemain

- uses: actions/checkout@v4
- name: REUSE Compliance Check
uses: fsfe/reuse-action@v5
- name: Validate Gradle Wrapper
uses: gradle/actions/[email protected]

publish:
needs: verify
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'

- name: Generate versions
uses: HardNorth/[email protected]
with:
version-source: file
version-file: gradle.properties
version-file-extraction-pattern: '(?<=version=).+'
next-version-increment-minor: true

- name: Validate Gradle
uses: gradle/actions/[email protected]

- name: Setup Gradle
uses: gradle/actions/[email protected]

- name: Git init
run: git config --global user.email "[email protected]" && git config --global user.name "CICD"

- name: Update version
run: ./gradlew :release -x build -Prelease.useAutomaticVersion=true -Prelease.releaseVersion=${{ env.RELEASE_VERSION }} -Prelease.newVersion=${{ env.NEXT_VERSION }} --no-parallel
cache: 'gradle'
- name: Build with Gradle
run: ./gradlew build
- name: Publish to Maven Central
env:
GITHUB_USER: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout release tag
uses: actions/checkout@v4
with:
ref: ${{ env.RELEASE_VERSION }}
fetch-depth: '0'

- name: Publish release
run: ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache
env:
GITHUB_USER: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.ORG_GRADLE_PROJECT_MAVENCENTRALUSERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.ORG_GRADLE_PROJECT_MAVENCENTRALPASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGINMEMORYKEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGINMEMORYKEYPASSWORD }}

- name: "Create release info"
uses: "actions/github-script@v7"
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
script: |
try {
const response = await github.rest.repos.createRelease({
draft: false,
generate_release_notes: true,
name: process.env.RELEASE_VERSION,
owner: context.repo.owner,
prerelease: false,
repo: context.repo.repo,
tag_name: process.env.RELEASE_VERSION,
});
core.exportVariable('RELEASE_ID', response.data.id);
core.exportVariable('RELEASE_UPLOAD_URL', response.data.upload_url);
} catch (error) {
core.setFailed(error.message);
}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.GPG_SUBKEY_ID }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_PRIVATE_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_PASSPHRASE }}
run: ./gradlew publishAllPublicationsToMavenCentralRepository
31 changes: 10 additions & 21 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,22 @@
#
# SPDX-License-Identifier: Apache-2.0

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle

name: Java CI with Gradle

on: [ push ]

jobs:
reuse-compliance-check:
verify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: REUSE Compliance Check
uses: fsfe/reuse-action@v5

validation:
name: "Gradle wrapper validation"
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: gradle/actions/[email protected]
- name: Validate Gradle Wrapper
uses: gradle/actions/[email protected]

build:
needs: verify
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -39,23 +28,23 @@ jobs:
with:
java-version: '21'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0
- name: Build with Gradle Wrapper
cache: 'gradle'
- name: Build with Gradle
run: ./gradlew build

dependency-submission:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
# Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies.
# See: https://github.com/gradle/actions/blob/main/dependency-submission/README.md
cache: 'gradle'
- name: Generate and submit dependency graph
uses: gradle/actions/dependency-submission@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0
uses: gradle/actions/dependency-submission@v4
4 changes: 2 additions & 2 deletions ReadMe.md → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ SPDX-FileCopyrightText: 2023 www.contributor-covenant.org
SPDX-License-Identifier: CC-BY-4.0
-->
![Build Status](https://github.com/eclipse-lmos/lmos-router/actions/workflows/gradle.yml/badge.svg)
[![Gradle Package](https://github.com/eclipse-lmos/lmos-router/actions/workflows/gradle-publish.yml/badge.svg)](https://github.com/eclipse-lmos/lmos-router/actions/workflows/gradle-publish.yml)
[![GitHub Actions Build Status](https://github.com/eclipse-lmos/lmos-router/actions/workflows/gradle.yml/badge.svg?branch=main)](https://github.com/eclipse-lmos/lmos-router/actions/workflows/gradle.yml)
[![GitHub Actions Publish Status](https://github.com/eclipse-lmos/lmos-router/actions/workflows/gradle-publish.yml/badge.svg?branch=main)](https://github.com/eclipse-lmos/lmos-router/actions/workflows/gradle-publish.yml)
[![Apache 2.0 License](https://img.shields.io/badge/license-Apache%202.0-green.svg)](https://www.apache.org/licenses/LICENSE-2.0)
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md)

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
kotlin.code.style=official
version=0.3.0-SNAPSHOT
version=0.1.0-SNAPSHOT

0 comments on commit 07d136e

Please sign in to comment.