-
Notifications
You must be signed in to change notification settings - Fork 76
156 lines (133 loc) · 5.25 KB
/
build.yaml
File metadata and controls
156 lines (133 loc) · 5.25 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
name: Release
on:
workflow_dispatch:
inputs:
EMBY_VERSION:
description: "The Emby server version (e.g., 4.8.11.0)."
type: string
required: true
default: 4.8.11.0
EMBY_REPLACEMENT_URL:
description: >-
URL for Emby's server replacement. Must starts with 'http' and end with '/'.
type: string
required: true
default: https://mb3admin.megm.workers.dev/
# remote_debug:
# description: >-
# Starts an SSH session to debug the runner. For advanced troubleshooting only.
# type: boolean
# required: false
# default: false
publish: # New input for publishing
description: "Publish to GitHub Release and create a tag"
type: boolean
required: false
default: false
jobs:
build: # This job will now handle both build and conditional release
runs-on: ubuntu-latest
env:
EMBY_REPLACEMENT_URL: ${{ inputs.EMBY_REPLACEMENT_URL }}
EMBY_VERSION: ${{ inputs.EMBY_VERSION }}
permissions: # Permissions needed for creating releases and tags in this job
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
# with:
# fetch-depth: 0 # Fetch all history for tag creation, needed for git tag
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 10
run_install: false
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
registry-url: https://registry.npmjs.org/
- name: Verify environment node
run: |
node --version
npm --version
pnpm --version
- name: Start debug session (when enabled)
if: ${{ inputs.remote_debug }}
uses: lhotari/action-upterm@v1
- name: Prepare Build Environment (via build.sh) # IMP-010: Renamed for clarity
run: |
./build.sh prepare:prepare
- name: Build
run: |
./build.sh
mv ./tmp/build/dist embyhack
- name: Validate artifact
run: test -d embyhack
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: docker-embyhack
path: embyhack
# --- Release steps, now conditional and within the 'build' job ---
- name: Create zip archive for release
run: zip -r docker-embyhack.zip embyhack
if: ${{ inputs.publish }} # Only run if publishing
- name: Get current date and time
id: date
if: ${{ inputs.publish }} # Only run if publishing
run: echo "NOW=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT
- name: Determine tag name
id: set_tag
if: ${{ inputs.publish }} # Only run if publishing
run: |
PRERELEASE_SUFFIX=""
if [[ "${{ github.ref_name }}" != "main" ]]; then
PRERELEASE_SUFFIX="-alpha"
fi
TAG_NAME="v${{ inputs.emby_version }}$PRERELEASE_SUFFIX+${{ steps.date.outputs.NOW }}"
RELEASE_NAME="Release $TAG_NAME"
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_OUTPUT
echo "RELEASE_NAME=$RELEASE_NAME" >> $GITHUB_OUTPUT
cat <<EOF > Release.txt
Automated release from GitHub Actions.
Branch: ${{ github.ref_name }}
Commit: ${{ github.sha }}
Build Date: ${{ steps.date.outputs.NOW }}
Emby Version: ${{ inputs.emby_version }}
EOF
cat Release.txt > Release_body.txt
echo "**This is a DRAFT release. Please verify the artifact before publishing.**" >> Release_body.txt
- name: Wait until continue
if: ${{ inputs.remote_debug }}
run: |
file_to_wait="./continue_debug"
# IMP-009: Improved clarity for the user
echo "Debug session started. To continue the workflow, create an empty file named '$file_to_wait' in the runner's workspace."
echo "Waiting for $file_to_wait to be created..."
while [ ! -f "$file_to_wait" ]; do
sleep 5 # Check every 5 seconds
echo "Still waiting for $file_to_wait..."
done
echo "$file_to_wait has been created. Proceeding with operations."
- name: Create and push tag
if: ${{ inputs.publish }} # Only run if publishing
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag ${{ steps.set_tag.outputs.TAG_NAME }}
git push origin ${{ steps.set_tag.outputs.TAG_NAME }}
- name: Create GitHub Release (as Draft)
if: ${{ inputs.publish }} # Only run if publishing
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.set_tag.outputs.TAG_NAME }}
name: ${{ steps.set_tag.outputs.RELEASE_NAME }}
body_path: Release_body.txt
draft: true # Set to true to create a draft release for manual verification
prerelease: ${{ github.ref_name != 'main' }} # Mark as prerelease if not on main branch
files: |
Release.txt
docker-embyhack.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GITHUB_TOKEN is automatically provided by GitHub Actions