Skip to content

Commit

Permalink
Release workflow (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
njooma authored May 9, 2024
1 parent e3e3a7a commit a1c822c
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 2 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Publish to Maven

on:
release:
types: [ published ]

jobs:
publish:
if: github.repository_owner == 'viamrobotics'
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.release.tag_name }}

- name: Setup Java JDK
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Setup Android SDK
uses: android-actions/setup-android@v3

- name: Build + Sign
run: ./gradlew signMavenPublication
env:
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.MAVEN_SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.MAVEN_SIGNING_PASSWORD }}

- name: Publish package
run: ./gradlew publish
env:
ORG_GRADLE_PROJECT_ossrhUsername: ${{ secrets.OSSRH_USERNAME }}
ORG_GRADLE_PROJECT_ossrhPassword: ${{ secrets.OSSRH_PASSWORD }}
77 changes: 77 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Release

on:
workflow_dispatch:

jobs:
prepare:
if: github.repository_owner == 'viamrobotics'
runs-on: ubuntu-latest
outputs:
version: ${{ steps.which_version.outputs.version }}
steps:
- uses: actions/checkout@v4

- name: Setup Java JDK
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Setup Android SDK
uses: android-actions/setup-android@v3

- name: Test
run: ./gradlew test

- name: Which Version
id: which_version
run: echo "version=$(./gradlew -q printVersion)" >> $GITHUB_OUTPUT

- name: Check if release exists
uses: cardinalby/[email protected]
id: release_exists
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
releaseName: v${{ steps.which_version.outputs.version }}
doNotFailIfNotFound: "true"

- name: Cancelling - release already exists
uses: andymckay/[email protected]
if: steps.release_exists.outputs.id != ''

- name: Build + Sign
run: ./gradlew signMavenPublication
env:
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.MAVEN_SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.MAVEN_SIGNING_PASSWORD }}

- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
path: |
**/build/libs/*
**/build/outputs/aar/*
if-no-files-found: error

release:
needs: [ prepare ]
if: github.repository_owner == 'viamrobotics'
runs-on: ubuntu-latest

steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: artifact
merge-multiple: true

- name: Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.prepare.outputs.version }}
draft: true
prerelease: ${{ contains(needs.prepare.outputs.version, 'SNAPSHOT') }}
files: artifact/**
fail_on_unmatched_files: true
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
branches: ["main"]

jobs:
license_finder:
test:
if: github.repository_owner == 'viamrobotics'
name: Test
runs-on: ubuntu-latest
Expand Down
8 changes: 7 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ subprojects {
username = findProperty("ossrhUsername")
password = findProperty("ossrhPassword")
}
if (version.endsWith('SNAPSHOT') || version.contains('.alpha.') || version.contains('.beta.') || version.contains('.rc.')) {
if (version.endsWith('SNAPSHOT')) {
url = snapshotsRepoUrl
} else {
url = releasesRepoUrl
Expand Down Expand Up @@ -196,3 +196,9 @@ subprojects {
dependsOn 'publishToMavenLocal'
}
}

tasks.register('printVersion') {
doLast {
println project.version
}
}

0 comments on commit a1c822c

Please sign in to comment.