@@ -17,43 +17,47 @@ jobs:
1717 with :
1818 fetch-depth : 0
1919
20- - name : Inject version into fabric.mod.json
20+ - name : Set environment variables
2121 run : |
2222 set -euo pipefail
2323 SHORT_SHA="${GITHUB_SHA:0:7}"
24+ echo "SHORT_SHA=$SHORT_SHA" >> $GITHUB_ENV
25+
2426 VERSION="v-$(date -u +%Y%m%d%H%M%S)-${SHORT_SHA}"
27+ echo "INJECTED_VERSION=$VERSION" >> $GITHUB_ENV
28+
29+ JAR_NAME="repo-${SHORT_SHA}.jar"
30+ echo "JAR_NAME=$JAR_NAME" >> $GITHUB_ENV
2531
26- jq --arg v "$VERSION" '.version = $v' fabric.mod.json > fabric.mod.json.tmp
32+ - name : Inject version into fabric.mod.json
33+ run : |
34+ set -euo pipefail
35+ jq --arg v "$INJECTED_VERSION" '.version = $v' fabric.mod.json > fabric.mod.json.tmp
2736 mv fabric.mod.json.tmp fabric.mod.json
2837
29- echo "INJECTED_VERSION=$VERSION" >> $GITHUB_ENV
30-
3138 - name : Create JAR of repository
3239 run : |
3340 set -euo pipefail
34- JAR_NAME="repo-${SHORT_SHA}.jar"
35-
36- # Build JAR safely, handling spaces in filenames
41+ # Build JAR safely, excluding .git, .github, and .gitignore
3742 find . -type f \
3843 ! -path "./.git/*" \
44+ ! -path "./.github/*" \
45+ ! -name ".gitignore" \
3946 ! -name "$JAR_NAME" \
4047 -print0 | xargs -0 jar cf "$JAR_NAME"
4148
42- echo "ZIP_NAME=$JAR_NAME" >> $GITHUB_ENV
43-
4449 - name : Create GitHub release and attach JAR
4550 env :
4651 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
47- ZIP_NAME : ${{ env.ZIP_NAME }}
48- TAG : ${{ env.INJECTED_VERSION }}
4952 run : |
5053 set -euo pipefail
51- TITLE="Automated release ${TAG}"
54+ TAG="$INJECTED_VERSION"
55+ TITLE="Automated release $TAG"
5256 NOTES="Automated release for commit ${GITHUB_SHA} on branch ${GITHUB_REF#refs/heads/}"
5357
54- gh release create "$TAG" "$ZIP_NAME " \
58+ gh release create "$TAG" "$JAR_NAME " \
5559 -t "$TITLE" \
5660 -n "$NOTES" \
5761 --repo "${{ github.repository }}"
5862
59- echo "Created release $TAG with asset $ZIP_NAME "
63+ echo "Created release $TAG with asset $JAR_NAME "
0 commit comments