Slice of ham #19
Workflow file for this run
This file contains hidden or 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: Build & Release | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| jar_name: ${{ steps.build.outputs.jar_name }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: 17 | |
| cache: gradle | |
| - name: Build | |
| id: build | |
| run: | | |
| chmod +x ./gradlew | |
| ./gradlew build | |
| JAR=$(find build/libs -maxdepth 1 -type f -name "*.jar" ! -name "*sources*" ! -name "*dev*" | head -n 1) | |
| echo "Found JAR: $JAR" | |
| echo "jar_name=$(basename "$JAR")" >> $GITHUB_OUTPUT | |
| - name: Upload JAR as artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: mod-jar | |
| path: build/libs/${{ steps.build.outputs.jar_name }} | |
| release: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Extract changelog section | |
| id: changelog | |
| run: | | |
| TAG="${GITHUB_REF_NAME}" | |
| BODY=$(awk "/^## $TAG/{flag=1;next}/^## /{flag=0}flag" CHANGELOG.md) | |
| if [ -z "$BODY" ]; then | |
| BODY="No changelog entry found for $TAG." | |
| fi | |
| echo "body<<EOF" >> $GITHUB_OUTPUT | |
| echo "$BODY" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| - name: Create GitHub Release | |
| id: create_release | |
| uses: actions/create-release@v1 | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| release_name: ${{ github.ref_name }} | |
| body: ${{ steps.changelog.outputs.body }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Download built jar | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: mod-jar | |
| path: dist | |
| - name: Upload Release Asset | |
| uses: actions/upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: dist/${{ needs.build.outputs.jar_name }} | |
| asset_name: ${{ needs.build.outputs.jar_name }} | |
| asset_content_type: application/java-archive |