Change release names #4
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: Package and Release JAR | |
| on: | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| contents: write | |
| jobs: | |
| jar-and-release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set environment variables | |
| run: | | |
| set -euo pipefail | |
| SHORT_SHA="${GITHUB_SHA:0:7}" | |
| echo "SHORT_SHA=$SHORT_SHA" >> $GITHUB_ENV | |
| VERSION="v-$(date -u +%Y%m%d%H%M%S)-${SHORT_SHA}" | |
| echo "INJECTED_VERSION=$VERSION" >> $GITHUB_ENV | |
| JAR_NAME="repo-${SHORT_SHA}.jar" | |
| echo "JAR_NAME=$JAR_NAME" >> $GITHUB_ENV | |
| - name: Inject version into fabric.mod.json | |
| run: | | |
| set -euo pipefail | |
| jq --arg v "$INJECTED_VERSION" '.version = $v' fabric.mod.json > fabric.mod.json.tmp | |
| mv fabric.mod.json.tmp fabric.mod.json | |
| - name: Create JAR of repository | |
| run: | | |
| set -euo pipefail | |
| # Build JAR safely, excluding .git, .github, and .gitignore | |
| find . -type f \ | |
| ! -path "./.git/*" \ | |
| ! -path "./.github/*" \ | |
| ! -name ".gitignore" \ | |
| ! -name "$JAR_NAME" \ | |
| -print0 | xargs -0 jar cf "$JAR_NAME" | |
| - name: Create GitHub release and attach JAR | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| set -euo pipefail | |
| TAG="$INJECTED_VERSION" | |
| TITLE="BTW CE Translations $TAG" | |
| NOTES="Automated release for commit ${GITHUB_SHA} on branch ${GITHUB_REF#refs/heads/}" | |
| gh release create "$TAG" "$JAR_NAME" \ | |
| -t "$TITLE" \ | |
| -n "$NOTES" \ | |
| --repo "${{ github.repository }}" | |
| echo "Created release $TAG with asset $JAR_NAME" |