Skip to content

Commit

Permalink
build: add new workflow (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
Snabeldier authored Sep 14, 2024
1 parent 65b01fa commit 6f711d8
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 18 deletions.
60 changes: 42 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,55 @@
name: SmartAPI | Maven-deployer

# This workflow is used to deploy a new maven-build of this api, whenever a new release is created.
# Always make sure to delete the latest package before creating a new release!
name: SmartAPI | Build and deploy

on:
release: # Triggers this workflow whenever a new release is created.
types: [published]
workflow_call:
inputs:
version:
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:
runs-on: ubuntu-latest

steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it.
- name: Repository-Checkout
uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v4

# Sets the current Java-version to 1.8.
- name: Set up to JDK 1.8
uses: actions/setup-java@v1
uses: actions/setup-java@v4
with:
java-version: 1.8.0
distribution: 'temurin'
cache: 'maven'
java-version: 8

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

# Deploys a maven-build as a new package to be accessed with any pom.xml.
- name: Deploy to GitHub
run: |
mvn source:jar
mvn deploy
- name: Build with Maven
run: mvn -B clean package
env:
GITHUB_TOKEN: ${{ secrets.DEPLOY_GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Deploy to GitHub Packages # Repository is set in pom.xml
run: mvn deploy
env:
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: 47 additions & 0 deletions .github/workflows/nightly-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: SmartAPI | Nightly Builder

on:
push:
branches:
- '**'

workflow_dispatch:

jobs:
get-latest-version:
name: Get latest version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version-ready.outputs.release }}
steps:
- name: Get latest release version
if: github.event_name == 'push'
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-latest-version
uses: ./.github/workflows/build.yml
with:
version: ${{ needs.get-latest-version.outputs.version }}-SNAPSHOT
isRelease: false
26 changes: 26 additions & 0 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: SmartAPI | Release Builder

on:
release:
types: [ published ]

jobs:
get-version:
name: Get Version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
steps:
- name: Get Version
id: get-version
run: |
TAG_NAME=${{ github.event.release.tag_name }}
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 6f711d8

Please sign in to comment.