-
Notifications
You must be signed in to change notification settings - Fork 307
142 lines (123 loc) · 5.42 KB
/
Copy pathcreate-release.yml
File metadata and controls
142 lines (123 loc) · 5.42 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: Create Release
on:
workflow_dispatch:
inputs:
version:
description: 'Version number (e.g., 1.26.0.2) — do not include the "v" prefix or "-preview" suffix'
required: true
type: string
release_notes_url:
description: 'URL to the release notes'
required: true
type: string
# Only allow dispatching from main or preview branches
run-name: "Release ${{ github.ref_name == 'preview' && format('v{0}-preview', inputs.version) || format('v{0}', inputs.version) }}"
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
# ── Validate inputs ───────────────────────────────────────────────
- name: Validate version format
run: |
VERSION="${{ inputs.version }}"
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::Version must be four dot-separated numbers (e.g., 1.26.0.2). Got: $VERSION"
exit 1
fi
- name: Validate branch
run: |
BRANCH="${{ github.ref_name }}"
if [[ "$BRANCH" != "main" && "$BRANCH" != "preview" ]]; then
echo "::error::This workflow can only be run from the 'main' or 'preview' branch. Current branch: $BRANCH"
exit 1
fi
# ── Compute tag and release metadata ──────────────────────────────
- name: Set release variables
id: vars
run: |
VERSION="${{ inputs.version }}"
BRANCH="${{ github.ref_name }}"
if [[ "$BRANCH" == "preview" ]]; then
TAG="v${VERSION}-preview"
PRERELEASE=true
MAKE_LATEST=false
else
TAG="v${VERSION}"
PRERELEASE=false
MAKE_LATEST=true
fi
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "prerelease=$PRERELEASE" >> "$GITHUB_OUTPUT"
echo "make_latest=$MAKE_LATEST" >> "$GITHUB_OUTPUT"
echo "### Release info" >> "$GITHUB_STEP_SUMMARY"
echo "- **Tag:** $TAG" >> "$GITHUB_STEP_SUMMARY"
echo "- **Branch:** $BRANCH" >> "$GITHUB_STEP_SUMMARY"
echo "- **Pre-release:** $PRERELEASE" >> "$GITHUB_STEP_SUMMARY"
# ── Checkout ──────────────────────────────────────────────────────
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}
# ── Build full zip ────────────────────────────────────────────────
- name: Build full zip
run: |
ZIP_NAME="bedrock-samples-${{ steps.vars.outputs.tag }}-full.zip"
zip -r "$ZIP_NAME" \
behavior_pack/ \
resource_pack/ \
documentation/ \
metadata/ \
README.md \
LICENSE.md \
CONTRIBUTING.md
# ── Build min zip (no binary files) ───────────────────────────────
- name: Build min zip
run: |
ZIP_NAME="bedrock-samples-${{ steps.vars.outputs.tag }}-min.zip"
zip -r "$ZIP_NAME" \
behavior_pack/ \
resource_pack/ \
documentation/ \
metadata/ \
README.md \
LICENSE.md \
CONTRIBUTING.md \
-x '*.png' \
-x '*.tga' \
-x '*.jpg' \
-x '*.fsb' \
-x '*.ogg' \
-x '*.pdn' \
-x '*.hdr'
# ── Verify LICENSE.md is in both zips ─────────────────────────────
- name: Verify LICENSE.md is present in both zips
run: |
FULL="bedrock-samples-${{ steps.vars.outputs.tag }}-full.zip"
MIN="bedrock-samples-${{ steps.vars.outputs.tag }}-min.zip"
for ZIP in "$FULL" "$MIN"; do
if ! unzip -l "$ZIP" | grep -q "LICENSE.md"; then
echo "::error::LICENSE.md is missing from $ZIP"
exit 1
fi
echo "✓ LICENSE.md found in $ZIP"
done
# ── Create GitHub Release ─────────────────────────────────────────
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.vars.outputs.tag }}
target_commitish: ${{ github.ref_name }}
name: ${{ steps.vars.outputs.tag }}
body: |
## Minecraft Bedrock Samples ${{ steps.vars.outputs.tag }}
**Release notes:** ${{ inputs.release_notes_url }}
### Assets
- **full** — Complete samples including all textures, models, and sounds
- **min** — Text-only samples (JSON, HTML, MD) with binary files excluded
prerelease: ${{ steps.vars.outputs.prerelease == 'true' }}
make_latest: ${{ steps.vars.outputs.make_latest == 'true' }}
files: |
bedrock-samples-${{ steps.vars.outputs.tag }}-full.zip
bedrock-samples-${{ steps.vars.outputs.tag }}-min.zip