diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e6fbedb..c6fc05b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,12 +19,15 @@ jobs: runs-on: ubuntu-latest if: | !contains(github.event.head_commit.message, '[ci skip]') + outputs: + version_info: ${{ steps.get_version.outputs.version_info }} + version_plain: ${{ steps.get_version.outputs.version_plain }} steps: - name: checkout repository uses: actions/checkout@v4.1.1 - name: validate gradle wrapper uses: gradle/wrapper-validation-action@v2.1.1 - - name: setup jdk 17 + - name: setup jdk uses: actions/setup-java@v4.1.0 with: distribution: 'temurin' @@ -32,25 +35,58 @@ jobs: cache: gradle - name: make gradle wrapper executable run: chmod +x ./gradlew - - name: build and publish + - name: build + run: ./gradlew build + - name: get version #https://stackoverflow.com/questions/71089787/how-to-get-version-name-from-android-gradle-file-in-github-actions + id: get_version + run: | + echo "version_info=$(${{github.workspace}}/gradlew -q printVersionName)" >> $GITHUB_OUTPUT + echo "version_plain=$(${{github.workspace}}/gradlew -q printVersion)" >> $GITHUB_OUTPUT + - name: capture build artifacts + uses: actions/upload-artifact@v4.3.1 + with: + name: Artifacts + path: build/libs/ + + packages: + needs: build + runs-on: ubuntu-latest + steps: + - name: checkout repository + uses: actions/checkout@v4.1.1 + - name: setup jdk + uses: actions/setup-java@v4.1.0 + with: + distribution: 'temurin' + java-version: 17 + cache: gradle + - name: make gradle wrapper executable + run: chmod +x ./gradlew + - name: publish env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - ./gradlew build publish + ./gradlew publish + + publish: + needs: build + runs-on: ubuntu-latest + if: ${{ github.event_name == 'workflow_dispatch' }} + steps: + - name: checkout repository + uses: actions/checkout@v4.1.1 + - uses: actions/download-artifact@v4.1.4 + with: + name: Artifacts + path: build/libs - - name: get version #https://stackoverflow.com/questions/71089787/how-to-get-version-name-from-android-gradle-file-in-github-actions - if: ${{ github.event_name == 'workflow_dispatch' }} - run: | - echo "VERSION_INFORMATION=$(${{github.workspace}}/gradlew -q printVersionName)" >> $GITHUB_ENV - echo "VERSION_PLAIN=$(${{github.workspace}}/gradlew -q printVersion)" >> $GITHUB_ENV - name: publish release - if: ${{ github.event_name == 'workflow_dispatch' }} uses: Kir-Antipov/mc-publish@v3.3.0 with: version-type: ${{ inputs.version_type }} changelog-file: CHANGELOG.md - name: ${{ env.VERSION_INFORMATION }} - version: ${{ env.VERSION_PLAIN }} + name: ${{ needs.build.outputs.version_info }} + version: ${{ needs.build.outputs.version_plain }} game-versions: | 1.20.4 @@ -61,7 +97,7 @@ jobs: java: | 17 - github-tag: ${{ env.VERSION_PLAIN }} + github-tag: v${{ needs.build.outputs.version_plain }} github-token: ${{ secrets.GITHUB_TOKEN }} github-commitish: ${{ github.sha }} github-prerelease: false