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

[Build] publish OSS artifacts through GitHub workflow #513

Closed
wants to merge 1 commit into from
Closed
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
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Continuous Integration

on:
workflow_call:
push:
branches:
- master
Expand All @@ -10,7 +11,7 @@ on:
- master

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: "CodeQL"

on:
workflow_call:
push:
branches:
- master
Expand All @@ -10,7 +11,7 @@ on:
- master

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
group: codeql-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
Expand Down
124 changes: 124 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
name: Release

on:
workflow_dispatch:
inputs:
release:
description: Is release? (Will create tag and update version)
required: true
default: false
type: boolean
release-version:
description: Released version (x.y.z)
required: true
type: string
next-version:
description: Next version (x.y.z)
required: true
type: string

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

env:
GRADLE_OPTS: '-Dorg.gradle.daemon=false -Dorg.gradle.java.installations.auto-detect=false -Dorg.gradle.warning.mode=fail'

jobs:
ci:
uses: ./.github/workflows/ci.yml

codeql:
uses: ./.github/workflows/codeql.yml

pre-release:
name: Update version, tag repo, and return sha
permissions:
contents: write
needs: [ ci, codeql ]
runs-on: ubuntu-latest
outputs:
sha: ${{ steps.return-sha.outputs.sha }}
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- id: validate
name: Validate no new commits
run: |
current_sha=$(git rev-parse HEAD)
if test $current_sha != '${{ github.sha }}'
then exit 1
fi
- id: tag-version
if: ${{ inputs.release }}
name: Update version and tag repo
run: |
git config user.name "github-actions"
git config user.email "[email protected]"
echo ${{ inputs.release-version }} > version.txt
git add version.txt
git status
git commit -m "${{ inputs.release-version }} version update."
git push
git tag ${{ inputs.release-version }}
git push origin refs/tags/${{ inputs.release-version }}
- id: return-sha
name: Return current SHA
run: |
git rev-parse HEAD
echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"

release:
name: Release java artifacts
permissions:
contents: read
packages: write
needs: pre-release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ needs.pre-release.outputs.sha }}
- name: Setup java
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 8
- name: Setup BUILD_JAVA_HOME & BUILD_JAVA_VERSION
run: |
java -Xinternalversion
echo "BUILD_JAVA_HOME=${JAVA_HOME}" >> $GITHUB_ENV
echo "BUILD_JAVA_VERSION=8" >> $GITHUB_ENV
- name: Publish with Gradle to Open Source
run: ./gradlew publishAllPublicationsToOssRepository
env:
ORG_GRADLE_PROJECT_repoUsername: ${{ secrets.osshrUsername }}
ORG_GRADLE_PROJECT_repoPassword: ${{ secrets.osshrPassword }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.signingKey }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.signingPassword }}

post-release:
name: Update version
permissions:
contents: write
needs: release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: Commit snapshot version to current branch
if: ${{ inputs.release }}
run: |
git config user.name "github-actions"
git config user.email "[email protected]"
echo ${{ inputs.next-version }}-SNAPSHOT > version.txt
git add version.txt
git status
git commit -m "${{ inputs.next-version }}-SNAPSHOT version update."
git push
55 changes: 48 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def agronaVersion = '1.21.2'
def sbeVersion = '1.31.1'
def aeronVersion = '1.44.1'
def artioGroup = 'uk.co.real-logic'
def iLink3Enabled = false
def artioVersion = file('version.txt').text.trim()

defaultTasks 'clean', 'build'

Expand Down Expand Up @@ -102,7 +102,9 @@ def projectPom = {

ext {
group = artioGroup
isReleaseVersion = !version.endsWith("SNAPSHOT")
isReleaseVersion = !artioVersion.endsWith("SNAPSHOT")
repoUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
snapshotUrl = 'https://oss.sonatype.org/content/repositories/snapshots/'
iLink3Enabled = Boolean.getBoolean("fix.core.iLink3Enabled")

if (!project.hasProperty('repoUsername')) {
Expand All @@ -113,12 +115,12 @@ ext {
repoPassword = ''
}

if (!project.hasProperty('repoUrl')) {
repoUrl = ''
if (!project.hasProperty('signingKey')) {
signingKey = null
}

if (!project.hasProperty('snapshotUrl')) {
snapshotUrl = ''
if (!project.hasProperty('signingPassword')) {
signingPassword = null
}
}

Expand Down Expand Up @@ -158,7 +160,7 @@ subprojects {
apply plugin: 'checkstyle'

group = artioGroup
version = version
version = artioVersion

def toolchainLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(buildJavaVersion)
Expand Down Expand Up @@ -286,6 +288,9 @@ subprojects {
}

signing {
if (signingKey != null) {
useInMemoryPgpKeys(signingKey, signingPassword)
}
required { isReleaseVersion && gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}
Expand Down Expand Up @@ -364,6 +369,9 @@ project(':artio-codecs') {
}

signing {
if (signingKey != null) {
useInMemoryPgpKeys(signingKey, signingPassword)
}
sign publishing.publications.artioCodecs
}
}
Expand Down Expand Up @@ -444,6 +452,9 @@ project(':artio-ilink3-codecs') {
}

signing {
if (signingKey != null) {
useInMemoryPgpKeys(signingKey, signingPassword)
}
sign publishing.publications.artioILink3Codecs
}
}
Expand Down Expand Up @@ -521,6 +532,9 @@ project(':artio-binary-entrypoint-codecs') {
}

signing {
if (signingKey != null) {
useInMemoryPgpKeys(signingKey, signingPassword)
}
sign publishing.publications.artioBinaryEntrypointCodecs
}
}
Expand All @@ -544,6 +558,9 @@ project(':artio-binary-entrypoint-impl') {
}

signing {
if (signingKey != null) {
useInMemoryPgpKeys(signingKey, signingPassword)
}
sign publishing.publications.artioBinaryEntrypointImpl
}
}
Expand Down Expand Up @@ -575,6 +592,9 @@ project(':artio-ilink3-impl') {
}

signing {
if (signingKey != null) {
useInMemoryPgpKeys(signingKey, signingPassword)
}
sign publishing.publications.artioIlink3Impl
}
}
Expand Down Expand Up @@ -641,6 +661,9 @@ project(':artio-session-codecs') {
}

signing {
if (signingKey != null) {
useInMemoryPgpKeys(signingKey, signingPassword)
}
sign publishing.publications.artioSessionCodecs
}
}
Expand Down Expand Up @@ -702,6 +725,9 @@ project(':artio-session-fixt-codecs') {
}

signing {
if (signingKey != null) {
useInMemoryPgpKeys(signingKey, signingPassword)
}
sign publishing.publications.artioSessionFixtCodecs
}
}
Expand Down Expand Up @@ -734,6 +760,9 @@ project(':artio-core') {
}

signing {
if (signingKey != null) {
useInMemoryPgpKeys(signingKey, signingPassword)
}
sign publishing.publications.artioCore
}
}
Expand Down Expand Up @@ -795,6 +824,9 @@ project(':artio-system-tests') {
}

signing {
if (signingKey != null) {
useInMemoryPgpKeys(signingKey, signingPassword)
}
sign publishing.publications.artioSystemTests
}
}
Expand Down Expand Up @@ -830,6 +862,9 @@ project(':artio-ilink-system-tests') {
}

signing {
if (signingKey != null) {
useInMemoryPgpKeys(signingKey, signingPassword)
}
sign publishing.publications.artioILink3SystemTests
}
}
Expand Down Expand Up @@ -860,6 +895,9 @@ project(':artio-binary-entrypoint-system-tests') {
}

signing {
if (signingKey != null) {
useInMemoryPgpKeys(signingKey, signingPassword)
}
sign publishing.publications.artioBinaryEntrypointSystemTests
}
}
Expand Down Expand Up @@ -892,6 +930,9 @@ project(':artio-samples') {
}

signing {
if (signingKey != null) {
useInMemoryPgpKeys(signingKey, signingPassword)
}
sign publishing.publications.artioSamples
}
}
Expand Down
1 change: 1 addition & 0 deletions version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.154-SNAPSHOT
Loading