Use a dedicated GitHub maven repository #2
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
name: Deployment | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- 'v*' | |
permissions: | |
contents: read | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
if: ${{ github.repository == 'GlennFolker/glTFrenzy' }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 17 | |
distribution: temurin | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v4 | |
- name: Set Artifact Version | |
run: | | |
if [ "${GITHUB_REF_TYPE}" = "tag" ]; then | |
# This is a release, so use the release's tag as the version. | |
echo "ARTIFACT_VERSION=${GITHUB_REF_NAME}" >> $GITHUB_ENV | |
elif [ "${GITHUB_REF_TYPE}" = "branch" ] && [ "${GITHUB_REF_NAME}" = "main" ]; then | |
# This is a bleeding-edge, so use the short commit's hash as the version. | |
echo "ARTIFACT_VERSION=$(git rev-parse --short=10 HEAD)" >> $GITHUB_ENV | |
else | |
# Sanity checks. | |
echo "Error: Unsupported branch '${GITHUB_REF_NAME}' or ref type '${GITHUB_REF_TYPE}'" >&2 | |
exit 1 | |
fi | |
- name: Publish Artifacts | |
run: | | |
chmod +x gradlew | |
./gradlew -P version="${ARTIFACT_VERSION}" -D maven.repo.local="$(pwd)/.out" publishToMavenLocal | |
git clone https://${{ secrets.MAVEN_TOKEN_GITHUB }}@github.com/GlennFolker/glTFrenzyMaven.git --depth=1 ../glTFrenzyMaven | |
cp -r .out/* ../glTFrenzyMaven | |
cd ../glTFrenzyMaven | |
git config user.name "GitHub Actions" | |
git config user.email "actions@github.com" | |
git add . | |
git commit -m "Publishing for ${ARTIFACT_VERSION}" | |
git push https://${{ secrets.MAVEN_TOKEN_GITHUB }}@github.com/GlennFolker/glTFrenzyMaven.git |