Skip to content

Commit 5469031

Browse files
committed
feat(ci): Add GitHub Actions workflow for publishing Bedrock releases
1 parent 2fa5125 commit 5469031

File tree

1 file changed

+119
-0
lines changed

1 file changed

+119
-0
lines changed
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
name: Publish Bedrock Release
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
paths:
9+
- 'bedrock/pack/RP/manifest.json'
10+
11+
jobs:
12+
check-version:
13+
name: Check version and prepare release
14+
runs-on: ubuntu-latest
15+
outputs:
16+
should_release: ${{ steps.version_check.outputs.should_release }}
17+
version: ${{ steps.version_check.outputs.version }}
18+
tag: ${{ steps.version_check.outputs.tag }}
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Setup Bun
26+
uses: oven-sh/setup-bun@v1
27+
with:
28+
bun-version: latest
29+
30+
- name: Check version and compare with tags
31+
id: version_check
32+
run: |
33+
# Read version from manifest.json
34+
VERSION=$(bun -e "const m = require('./bedrock/pack/RP/manifest.json'); console.log(m.header.version.join('.'))")
35+
echo "Manifest version: $VERSION"
36+
echo "version=$VERSION" >> $GITHUB_OUTPUT
37+
echo "tag=v$VERSION" >> $GITHUB_OUTPUT
38+
39+
# Get latest git tag
40+
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
41+
echo "Latest tag: $LATEST_TAG"
42+
43+
# Remove 'v' prefix for comparison
44+
LATEST_VERSION=${LATEST_TAG#v}
45+
46+
# Compare versions
47+
if [ "$VERSION" = "$LATEST_VERSION" ]; then
48+
echo "Version $VERSION already released"
49+
echo "should_release=false" >> $GITHUB_OUTPUT
50+
else
51+
# Simple version comparison (assumes semantic versioning)
52+
NEWER=$(printf '%s\n%s\n' "$LATEST_VERSION" "$VERSION" | sort -V | tail -n1)
53+
if [ "$NEWER" = "$VERSION" ] && [ "$VERSION" != "$LATEST_VERSION" ]; then
54+
echo "New version detected: $VERSION > $LATEST_VERSION"
55+
echo "should_release=true" >> $GITHUB_OUTPUT
56+
else
57+
echo "Version $VERSION is not higher than $LATEST_VERSION"
58+
echo "should_release=false" >> $GITHUB_OUTPUT
59+
fi
60+
fi
61+
62+
build:
63+
name: Build Bedrock packs
64+
needs: check-version
65+
if: needs.check-version.outputs.should_release == 'true'
66+
runs-on: ubuntu-latest
67+
steps:
68+
- name: Checkout
69+
uses: actions/checkout@v4
70+
71+
- name: Setup Bun
72+
uses: oven-sh/setup-bun@v1
73+
with:
74+
bun-version: latest
75+
76+
- name: Install dependencies
77+
run: bun install --frozen-lockfile
78+
79+
- name: Build packs (CI mode)
80+
env:
81+
CI: 'true'
82+
run: bun ./src/scripts/build-packs.ts --ci
83+
84+
- name: Upload .mcpack artifacts
85+
uses: actions/upload-artifact@v4
86+
with:
87+
name: bedrock-mcpacks
88+
path: dist/**/*.mcpack
89+
if-no-files-found: error
90+
91+
release:
92+
name: Create GitHub Release
93+
needs: [check-version, build]
94+
if: needs.check-version.outputs.should_release == 'true'
95+
runs-on: ubuntu-latest
96+
permissions:
97+
contents: write
98+
steps:
99+
- name: Checkout
100+
uses: actions/checkout@v4
101+
102+
- name: Download artifacts
103+
uses: actions/download-artifact@v4
104+
with:
105+
name: bedrock-mcpacks
106+
path: ./release-assets
107+
108+
- name: Create Release
109+
uses: softprops/action-gh-release@v1
110+
with:
111+
tag_name: ${{ needs.check-version.outputs.tag }}
112+
name: JG RTX Bedrock ${{ needs.check-version.outputs.version }}
113+
draft: false
114+
prerelease: false
115+
generate_release_notes: true
116+
files: |
117+
./release-assets/**/*.mcpack
118+
env:
119+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)