Skip to content

Commit 5fc2965

Browse files
committed
Locked in
1 parent d5a3656 commit 5fc2965

File tree

4 files changed

+49
-67
lines changed

4 files changed

+49
-67
lines changed

.github/workflows/build-and-release.yml

Lines changed: 39 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -2,107 +2,81 @@ name: Build & Release
22

33
on:
44
push:
5-
branches: [ main ]
65
tags:
7-
- 'v*'
8-
workflow_dispatch:
6+
- "v*"
97

108
permissions:
119
contents: write
1210

1311
jobs:
1412
build:
1513
runs-on: ubuntu-latest
16-
name: Mod Building
17-
1814
outputs:
19-
version: ${{ steps.version.outputs.version }}
20-
filename: ${{ steps.build.outputs.filename }}
15+
jar_file: ${{ steps.build.outputs.jar_file }}
2116

2217
steps:
23-
- name: Checkout repository
18+
- name: Checkout
2419
uses: actions/checkout@v4
2520

2621
- name: Setup Java
2722
uses: actions/setup-java@v4
2823
with:
29-
distribution: 'temurin'
30-
java-version: '17'
24+
distribution: temurin
25+
java-version: 17
3126
cache: gradle
3227

33-
- name: Grant execute permission for gradlew
34-
run: chmod +x gradlew
35-
36-
- name: Build project
28+
- name: Build
3729
id: build
3830
run: |
31+
chmod +x ./gradlew
3932
./gradlew build
40-
JAR_FILE=$(ls build/libs/*.jar | grep -v sources | head -1)
41-
echo "filename=$(basename $JAR_FILE)" >> $GITHUB_OUTPUT
4233
43-
- name: Get version from gradle.properties
44-
id: version
45-
run: |
46-
VERSION=$(grep "^mod_version=" gradle.properties | cut -d'=' -f2)
47-
echo "version=$VERSION" >> $GITHUB_OUTPUT
48-
49-
- name: Upload build artifacts
50-
uses: actions/upload-artifact@v4
51-
with:
52-
name: mod-build
53-
path: build/libs/
34+
JAR=$(ls build/libs/*.jar | grep -v sources | head -1)
35+
echo "jar_file=$JAR" >> $GITHUB_OUTPUT
5436
5537
release:
5638
needs: build
5739
runs-on: ubuntu-latest
58-
name: Create Release
59-
if: startsWith(github.ref, 'refs/tags/v')
6040

6141
steps:
62-
- name: Checkout (fetch tags)
42+
- name: Checkout
6343
uses: actions/checkout@v4
44+
with:
45+
fetch-depth: 0
6446

65-
- name: Determine tag and annotated message
66-
id: taginfo
47+
- name: Extract changelog section
48+
id: changelog
6749
run: |
68-
TAG=${GITHUB_REF##*/}
69-
echo "tag=$TAG" >> $GITHUB_OUTPUT
70-
# Try to read annotated tag contents
71-
BODY=$(git for-each-ref --format='%(contents)' refs/tags/$TAG 2>/dev/null || true)
72-
if [ -z "$BODY" ]; then
73-
BODY=$(git tag -l --format='%(contents)' "$TAG" 2>/dev/null || true)
74-
fi
75-
# Fallback to commit message if no tag message
50+
TAG="${GITHUB_REF_NAME}"
51+
52+
# Extract the section for this version
53+
BODY=$(awk "/^## $TAG/{flag=1;next}/^## /{flag=0}flag" CHANGELOG.md)
54+
55+
# Fallback if there's no entry
7656
if [ -z "$BODY" ]; then
77-
BODY=$(git log -1 --pretty=%B)
57+
BODY="No changelog entry found for $TAG."
7858
fi
59+
7960
echo "body<<EOF" >> $GITHUB_OUTPUT
8061
echo "$BODY" >> $GITHUB_OUTPUT
8162
echo "EOF" >> $GITHUB_OUTPUT
8263
83-
- name: Download artifacts
84-
uses: actions/download-artifact@v4
85-
with:
86-
name: mod-build
87-
path: ./artifacts
88-
8964
- name: Create GitHub Release
9065
id: create_release
91-
run: |
92-
RESPONSE=$(curl -X POST \
93-
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
94-
-H "Accept: application/vnd.github.v3+json" \
95-
https://api.github.com/repos/${{ github.repository }}/releases \
96-
-d "{\"tag_name\":\"${{ steps.taginfo.outputs.tag }}\",\"name\":\"${{ steps.taginfo.outputs.tag }}\",\"body\":$(echo '${{ steps.taginfo.outputs.body }}' | jq -Rs .),\"draft\":false,\"prerelease\":false}")
97-
98-
UPLOAD_URL=$(echo $RESPONSE | jq -r '.upload_url' | sed 's/{?name,label}//')
99-
echo "upload_url=$UPLOAD_URL" >> $GITHUB_OUTPUT
100-
101-
- name: Upload release asset
102-
run: |
103-
JAR_FILE=$(ls artifacts/*.jar | grep -v sources | head -1)
104-
curl -X POST \
105-
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
106-
-H "Content-Type: application/octet-stream" \
107-
--data-binary @"$JAR_FILE" \
108-
"${{ steps.create_release.outputs.upload_url }}?name=$(basename $JAR_FILE)"
66+
uses: actions/create-release@v1
67+
with:
68+
tag_name: ${{ github.ref_name }}
69+
release_name: ${{ github.ref_name }}
70+
body: ${{ steps.changelog.outputs.body }}
71+
env:
72+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73+
74+
- name: Upload Release Asset
75+
uses: actions/upload-release-asset@v1
76+
env:
77+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78+
with:
79+
upload_url: ${{ steps.create_release.outputs.upload_url }}
80+
asset_path: ${{ needs.build.outputs.jar_file }}
81+
asset_name: $(basename ${{ needs.build.outputs.jar_file }})
82+
asset_content_type: application/java-archive

.github/workflows/pr-validation.yml renamed to .github/workflows/validation.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: PR Validation
1+
name: Validation
22

33
on:
44
pull_request:
@@ -43,4 +43,4 @@ jobs:
4343
with:
4444
name: build-artifacts
4545
path: build/libs/
46-
retention-days: 7
46+
retention-days: 1

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented here.
4+
5+
## v1.0.0 - 11/14/2025
6+
### Initial Release
7+
- Initial set of discs.
8+
- New villager profession (DJ) via jukebox.

src/main/resources/discs.png

23.2 KB
Loading

0 commit comments

Comments
 (0)