forked from MineValley/CoreAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add release build support to GitHub Actions workflow
Signed-off-by: Valentin Sickert <[email protected]>
- Loading branch information
Showing
3 changed files
with
53 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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: | ||
|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters