-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit includes the CI setup for packaging the jarfile and hosti…
…ng them on GitHub's package manager
- Loading branch information
1 parent
23800f8
commit 69def2f
Showing
2 changed files
with
53 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Deploy to GitHub Packages | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- feat/ci-cd | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up JDK | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: '17' | ||
distribution: 'adopt' | ||
|
||
- name: Add execute permissions to script | ||
run: chmod +x ./check-version.sh | ||
|
||
- name: Check if version exists | ||
id: chkvrsn | ||
run: ./check-version.sh | ||
env: | ||
PAT: ${{ secrets.PAT }} | ||
USER: ${{ secrets.USER }} | ||
|
||
- name: Build with Maven | ||
run: mvn -B package --file pom.xml | ||
|
||
- name: Publish to GitHub Packages | ||
run: mvn deploy | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.PAT }} | ||
if: ${{ steps.chkvrsn.outputs.exists == '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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec) | ||
URL=https://maven.pkg.github.com/arkaprovob/gamedoora-model/com/gamedoora/gamedoora-model/$VERSION/gamedoora-model-$VERSION.pom | ||
STATUS_CODE=$(curl --silent --output /dev/null --write-out "%{http_code}\n" -u ${USER}:${PAT} $URL) | ||
|
||
if [ $STATUS_CODE -eq 404 ]; then | ||
echo "::set-output name=exists::false" | ||
echo "Version $VERSION does not exist, proceeding with the artifact upload." | ||
else | ||
echo "::set-output name=exists::true" | ||
echo "Version $VERSION already exists." | ||
fi |