fix: README workflow status badge #32
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: Publish package to GitHub Packages | |
on: | |
push: | |
branches: [ "main" ] | |
jobs: | |
version: | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.version.outputs.version }} | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: thecodemonkey/action-get-gradle-version@master | |
id: version | |
- run: 'echo version ${{ steps.version.outputs.version }}' | |
publish: | |
needs: version | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-java@v4 | |
with: | |
java-version: '21' | |
distribution: 'temurin' | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 | |
- name: Compare with published version | |
id: compare_versions | |
run: | | |
PUBLISHED_VERSION=$(curl -s \ | |
-u ${{ secrets.GITHUB_USERNAME }}:${{ secrets.GITHUB_TOKEN }} \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
/~https://github.com/IanTapply22/Wynncraft/packages/2160010?version=${{needs.version.outputs.version}}) | |
if [[ "$PUBLISHED_VERSION" == *"${{needs.version.outputs.version}}"* ]]; then | |
echo "Version is already published. Skipping publish step." | |
echo "::set-output name=skip::true" | |
else | |
echo "Version not published. Proceeding with publish step." | |
echo "::set-output name=skip::false" | |
fi | |
- name: Publish package | |
if: steps.compare_versions.outputs.skip != 'true' | |
run: ./gradlew publish | |
env: | |
GITHUB_USERNAME: IanTapply22 | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |