Skip to content

Commit

Permalink
Update with the latest conventions and workflows (#99)
Browse files Browse the repository at this point in the history
* Update with the latest conventions and workflows

Release prep.

Add conventions for releasing to Maven Central
And while at it, add some for common setup and coverage
  • Loading branch information
big-andy-coates authored Nov 4, 2022
1 parent 83d6b3b commit 85cf94c
Show file tree
Hide file tree
Showing 16 changed files with 462 additions and 224 deletions.
21 changes: 21 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
changelog:
exclude:
labels:
- documentation
- subtask
- chore
categories:
- title: Breaking Changes 🛠
labels: [ breaking-change ]

- title: Exciting New Features 🎉
labels: [ enhancement ]

- title: Bug Fixes 🎉
labels: [ bug ]

- title: Dependency Updates
labels: [ dependencies ]

- title: Less Exciting Things
labels: [ "*" ]
63 changes: 63 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# 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://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle

name: Build

on:
push:
branches: [ main ]
tags: [ "v*.*.*" ]
pull_request:
branches: [ main ]
workflow_dispatch:
inputs:
publish_artifacts:
description: "Publish release artifacts: true or false?"
default: "true"

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Fetch version history
# Do NOT want to fetch all tags if build specific tag.
# Doing so could result in code published with wrong version, if newer tags have been pushed
if: (!startsWith(github.ref, 'refs/tags/'))
run: git fetch --tag --unshallow
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
run: ./gradlew check coveralls
- name: Publish
if: github.event_name == 'push' || github.event.inputs.publish_artifacts == 'true'
env:
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGKEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGPASSWORD }}
ORG_GRADLE_PROJECT_SONA_USERNAME: ${{ secrets.SONA_USERNAME }}
ORG_GRADLE_PROJECT_SONA_PASSWORD: ${{ secrets.SONA_PASSWORD }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./gradlew cV
./gradlew publish closeSonatypeStagingRepository # todo: switch to releasing once happy.
create-gh-release:
if: startsWith(github.ref, 'refs/tags/') && !endsWith(github.ref, '-alpha')
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/[email protected]
- name: Create GitHut Release
uses: softprops/action-gh-release@v1
with:
generate_release_notes: true
8 changes: 2 additions & 6 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: CodeQL

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

Expand All @@ -22,7 +20,7 @@ jobs:

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

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
Expand All @@ -40,9 +38,7 @@ jobs:
run: chmod +x gradlew

- name: Build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew
run: ./gradlew test

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
44 changes: 0 additions & 44 deletions .github/workflows/gradle.yml

This file was deleted.

33 changes: 33 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# A Workflow for triggering a new release.

name: Release

on: [workflow_dispatch]

concurrency: "${{ github.repository }}-versioning"

jobs:
release:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/[email protected]
with:
token: ${{ secrets.TRIGGER_GITHUB_TOKEN }}
- name: Fetch version history
run: git fetch --tags --unshallow
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Ensure build is green
run: ./gradlew check
- name: Release
run: |
# The following command will trigger the build.yml workflow as it pushes a release tag
./gradlew release
30 changes: 20 additions & 10 deletions .github/workflows/version.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
name: Version
# A Workflow for adjusting the version number of the next release

name: Set next version

on:
workflow_dispatch:
inputs:
part:
description: "Part to increment: Major, Minor or Patch"
description: "Part to increment: Major, Minor, Patch or the next release, e.g. 1.2.3"
required: true
default: Patch
default: Minor

concurrency: "${{ github.repository }}-versioning"

jobs:
version:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/[email protected]
with:
token: ${{ secrets.TRIGGER_GITHUB_TOKEN }}
- name: Fetch version history
run: git fetch --tags --unshallow
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
Expand All @@ -21,12 +30,13 @@ jobs:
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Increment Version Part
- name: Increment version
if: contains(fromJson('["Major", "Minor", "Patch"]'), github.event.inputs.part)
run: |
git fetch --tags --unshallow
# The following command will trigger the build.yml workflow as it pushes a alpha tag
./gradlew markNextVersion -Prelease.incrementer=increment${{ github.event.inputs.part }}
- name: Trigger Build
- name: Set next version
if: (!contains(fromJson('["Major", "Minor", "Patch"]'), github.event.inputs.part))
run: |
curl -H "Accept: application/vnd.github.v3+json" -H "Authorization: token ${GITHUB_TOKEN}" "https://api.github.com/repos/${{ github.repository }}/actions/workflows/gradle.yml/dispatches" -d '{"ref":"main","inputs":{"publish":"true"}}'
env:
GITHUB_TOKEN: ${{ secrets.TRIGGER_GITHUB_TOKEN }}
# The following command will trigger the build.yml workflow as it pushes a alpha tag
./gradlew markNextVersion -Prelease.version=${{ github.event.inputs.part }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ out
*.ipr
*.iws
.idea

# Apple
**/.DS_Store
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Coverage Status](https://coveralls.io/repos/github/creek-service/creek-base/badge.svg?branch=main)](https://coveralls.io/github/creek-service/creek-base?branch=main)
[![build](https://github.com/creek-service/creek-base/actions/workflows/gradle.yml/badge.svg)](https://github.com/creek-service/creek-base/actions/workflows/gradle.yml)
[![build](https://github.com/creek-service/creek-base/actions/workflows/build.yml/badge.svg)](https://github.com/creek-service/creek-base/actions/workflows/build.yml)
[![CodeQL](https://github.com/creek-service/creek-base/actions/workflows/codeql.yml/badge.svg)](https://github.com/creek-service/creek-base/actions/workflows/codeql.yml)

# Creek Base
Expand Down
Loading

0 comments on commit 85cf94c

Please sign in to comment.