Skip to content

Commit

Permalink
Release workflow (#10)
Browse files Browse the repository at this point in the history
* Updated gradle to include publishing version

* Update main-ci.yml

* Update main-release.yml

---------

Co-authored-by: ben_pollard <ben@singerinstruments.com>
  • Loading branch information
benpollarduk and ben_pollard authored Jan 23, 2024
1 parent b892bac commit 2f16632
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 22 deletions.
20 changes: 5 additions & 15 deletions .github/workflows/main-ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# main ci workflow is to ensure the codebase builds with the gradle wrapper.
# all unit tests must pass for the workflow to complete successfully.
# a JaCoCo coverage report will be published as an artifact.

name: main-ci

on:
Expand All @@ -22,25 +18,19 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'

- name: Execute Gradle build, test and Jacoco test report generation
run: |
sh ./gradlew build test jacocotestreport
- name: Publish JaCoCo test report
run: |
mkdir -p ${{ github.workspace }}/build/reports/jacoco/test
cp -r ktaf/build/reports/jacoco/test jacoco-report
if: always()
- name: Upload JaCoCo test report
uses: actions/upload-artifact@v3
with:
name: jacoco-report
path: jacoco-report
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
Expand Down
58 changes: 53 additions & 5 deletions .github/workflows/main-release.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# main release workflow for ktaf.
# build and tests the code and if successful publishes the package.

name: main-release

on:
workflow_dispatch:
inputs:
ver:
description: 'The version number, should be specified as a semantic version e.g: X.Y.Z'
required: true
release-notes:
description: 'The versions release notes'
required: true

jobs:
build:
Expand All @@ -14,14 +18,58 @@ jobs:
PUBLISH_URL: ${{ vars.PUBLISH_URL }}
PUBLISH_USERNAME: ${{ vars.PUBLISH_USERNAME }}
PUBLISH_PASSWORD: ${{ secrets.PUBLISH_PASSWORD }}
PUBLISH_VERSION: ${{ inputs.ver }}

steps:
- uses: actions/checkout@v3
- name: Checkout repository
uses: actions/checkout@v3
with:
repository: benpollarduk/ktaf
token: ${{ secrets.PAT }}

- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'

- name: Execute Gradle build and test and then publish
run: |
sh ./gradlew build test :ktaf:publish -PpublishUrl=${PUBLISH_URL} -PpublishUsername=${PUBLISH_USERNAME} -PpublishPassword=${PUBLISH_PASSWORD}
sh ./gradlew build test :ktaf:publish -PpublishVersion=${PUBLISH_VERSION} -PpublishUrl=${PUBLISH_URL} -PpublishUsername=${PUBLISH_USERNAME} -PpublishPassword=${PUBLISH_PASSWORD}
- name: Tag the commit
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git tag -a "${{ inputs.ver }}" -m "${{ inputs.ver }} tagged during GitHub action"
git push --tags
- name: Build dokka documentation
run: |
sh ./gradlew build test :ktaf:dokkaHtml -PpublishVersion=${PUBLISH_VERSION}
- name: Copy website files, commit and tag, then push changes to ktaf-docs
run: |
mkdir ktaf-docs
cd ktaf-docs
git init
git remote add origin https://${{ secrets.PAT }}@github.com/benpollarduk/ktaf-docs.git
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git fetch
git checkout main
git rm -r --ignore-unmatch .
cp -r ../ktaf/build/dokka/html/* .
git add .
git commit -m "Update documentation"
git tag -a "${{ inputs.ver }}" -m "${{ inputs.ver }} tagged during GitHub action"
git push --follow-tags origin main:main
- name: Create GitHub release
uses: actions/create-release@v1
with:
tag_name: "${{ inputs.ver }}"
release_name: "${{ inputs.ver }}"
body: "${{ inputs.release-notes }}"
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
artifactId=ktaf
artifactGroup=com.github.benpollarduk
publishVersion=0.0.0
publishUrl=https://maven.pkg.github.com/benpollarduk/ktaf
publishUsername=
publishPassword=
4 changes: 2 additions & 2 deletions ktaf/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ plugins {
// Publishing properties defined at a project level gradle.properties.
val artifactId: String by project
val artifactGroup: String by project
val ver = "1.2.0"
val publishVersion: String by project

ext {
// Set the version.
version = ver
version = publishVersion
}

repositories {
Expand Down

0 comments on commit 2f16632

Please sign in to comment.