-
Notifications
You must be signed in to change notification settings - Fork 7
77 lines (63 loc) · 2.37 KB
/
Copy pathrelease.yml
File metadata and controls
77 lines (63 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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
# Always use the same JAR name
JAR_NAME="btw-translations.jar"
echo "JAR_NAME=$JAR_NAME" >> $GITHUB_ENV
- name: Inject version into fabric.mod.json
run: |
set -euo pipefail
# Read current version from fabric.mod.json
CURRENT_VERSION=$(jq -r '.version' fabric.mod.json)
echo "Current version: $CURRENT_VERSION"
# Extract major and minor parts (e.g., 1.0 from 1.0.0-dev)
MAJOR_MINOR=$(echo "$CURRENT_VERSION" | sed -E 's/^([0-9]+\.[0-9]+).*/\1/')
# Use GitHub run number as patch
PATCH="$GITHUB_RUN_NUMBER"
# Construct new version: 1.0.X
INJECTED_VERSION="${MAJOR_MINOR}.${PATCH}"
echo "INJECTED_VERSION=$INJECTED_VERSION" >> $GITHUB_ENV
# Update fabric.mod.json with new version
jq --arg v "$INJECTED_VERSION" '.version = $v' fabric.mod.json > fabric.mod.json.tmp
mv fabric.mod.json.tmp fabric.mod.json
# Set release title using version
RELEASE_TITLE="BTW Translations Nightly $INJECTED_VERSION"
echo "RELEASE_TITLE=$RELEASE_TITLE" >> $GITHUB_ENV
- name: Create JAR of repository
run: |
set -euo pipefail
# Build JAR 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="$RELEASE_TITLE"
NOTES="Automated nightly 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"