Skip to content

Commit

Permalink
Add release build support to GitHub Actions workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Valentin Sickert <[email protected]>
  • Loading branch information
Lapotor committed Jan 14, 2024
1 parent a9119c4 commit 07a0a6d
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 23 deletions.
24 changes: 22 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ on:
description: 'The version of the new build.'
required: true
type: string
isRelease:
description: 'Is this a release build?'
required: true
type: boolean

permissions:
contents: write
packages: write

jobs:
build:
Expand All @@ -23,10 +31,22 @@ jobs:
cache: 'maven'
java-version: 8

- name: Set Project Version
run: mvn versions:set -DnewVersion=${{ inputs.version }}

- name: Build with Maven
run: mvn source:jar -DapiVersion=${{ inputs.version }}
run: mvn -B clean package

- name: Deploy to GitHub Packages # Repository is set in pom.xml
run: mvn deploy
env:
GITHUB_TOKEN: ${{ secrets.DEPLOY_GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload assets to release
if: ${{ inputs.isRelease }}
uses: softprops/[email protected]
with:
files: |
target/api-${{ inputs.version }}.jar
target/api-${{ inputs.version }}-sources.jar
target/api-${{ inputs.version }}-javadoc.jar
47 changes: 29 additions & 18 deletions .github/workflows/nightly-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,45 @@ name: Core-API | Nightly Builder
on:
push:
branches:
- master
- '**'

workflow_dispatch:
inputs:
version:
description: 'Version to build'
required: true
type: string

jobs:
get-version:
name: Get version
get-latest-version:
name: Get latest version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.set-version-push.outputs.version || steps.set-version.outputs.version }}
version: ${{ steps.version-ready.outputs.release }}
steps:
- name: Set short commit hash on push
- name: Get latest release version
if: github.event_name == 'push'
id: set-version-push
run: echo ::set-output name=version::$(git rev-parse --short HEAD)
- name: Set version from input
if: github.event_name == 'workflow_dispatch'
id: set-version
run: echo ::set-output name=version::${{ github.event.inputs.version }}
id: get-latest-version
uses: pozetroninc/[email protected]
with:
repository: ${{ github.repository }}

- name: Increment version
if: github.event_name == 'push'
id: increment-version
run: |
RELEASE_NAME=${{ steps.get-latest-version.outputs.release }}
echo "release=$(echo ${RELEASE_NAME#v} | awk -F. -v OFS=. '{$NF = $NF + 1;} 1')" >> "$GITHUB_OUTPUT"
- name: Set output
id: version-ready

run: |
if [[ "${{ github.ref_name}}" == "main" || "${{ github.ref_name }}" == "master" ]]; then
echo "release=${{ steps.increment-version.outputs.release }}" >> "$GITHUB_OUTPUT"
else
echo "release=${{ github.ref_name }}_${{ steps.increment-version.outputs.release }}" >> "$GITHUB_OUTPUT"
fi
build-nightly:
name: Build Nightly version
needs: get-version
needs: get-latest-version
uses: ./.github/workflows/build.yml
with:
version: ${{ needs.get-version.outputs.version }}
version: ${{ needs.get-latest-version.outputs.version }}-SNAPSHOT
isRelease: false
5 changes: 2 additions & 3 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@ jobs:
id: get-version
run: |
TAG_NAME=${{ github.event.release.tag_name }}
echo ::set-output name=version::${TAG_NAME#v}
echo "version=${TAG_NAME#v}" >> "$GITHUB_OUTPUT"
build-release:
name: Build Release
needs: get-version
uses: ./.github/workflows/build.yml
with:
version: ${{ needs.get-version.outputs.version }}


isRelease: true

0 comments on commit 07a0a6d

Please sign in to comment.