forked from dcflachs/compose_plugin
-
Notifications
You must be signed in to change notification settings - Fork 2
193 lines (163 loc) · 6.08 KB
/
build.yml
File metadata and controls
193 lines (163 loc) · 6.08 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# .github/workflows/build.yml
# CI/CD pipeline for Compose Manager plugin
#
# This workflow automates the release process:
# - Builds TXZ package using Docker (Slackware)
# - Calculates MD5 for integrity verification
# - Creates GitHub releases with package attached
# - Updates PLG file in dev branch
#
# Triggers:
# - New tag matching date pattern: vYYYY.MM.DD[a-z]
# - Manual workflow_dispatch for testing builds
name: Build & Release Plugin
on:
push:
tags:
- 'v20[0-9][0-9].[0-9][0-9].[0-9][0-9]*'
workflow_dispatch:
inputs:
version:
description: 'Version to build (e.g., 2026.02.01) - leave empty for test build'
required: false
default: ''
permissions:
contents: write
env:
PLUGIN_NAME: compose.manager
COMPOSE_VERSION: '2.40.3'
COMPOSE_SWITCH_VERSION: '1.0.5'
ACE_VERSION: '1.4.14'
jobs:
build:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.VERSION }}
md5: ${{ steps.hash.outputs.MD5 }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Determine version
id: version
run: |
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == refs/tags/v* ]]; then
# Release tag - extract version (remove 'v' prefix)
VERSION="${GITHUB_REF#refs/tags/v}"
elif [[ -n "${{ github.event.inputs.version }}" ]]; then
# Manual input
VERSION="${{ github.event.inputs.version }}"
else
# Test build - use date + git SHA
VERSION="$(date +%Y.%m.%d)-dev.$(git rev-parse --short HEAD)"
fi
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
echo "Building version: ${VERSION}"
- name: Build TXZ package in Docker
run: |
VERSION="${{ steps.version.outputs.VERSION }}"
# Set executable permissions
chmod +x ./build_in_docker.sh
chmod +x ./source/pkg_build.sh
# Build using the Slackware Docker container
docker run --rm --tmpfs /tmp \
-v $PWD/archive:/mnt/output:rw \
-v $PWD/source:/mnt/source:ro \
-e TZ="America/New_York" \
-e COMPOSE_VERSION=${{ env.COMPOSE_VERSION }} \
-e COMPOSE_SWITCH_VERSION=${{ env.COMPOSE_SWITCH_VERSION }} \
-e ACE_VERSION=${{ env.ACE_VERSION }} \
-e OUTPUT_FOLDER="/mnt/output" \
-e PKG_VERSION="${VERSION}" \
vbatts/slackware:latest /mnt/source/pkg_build.sh
# Verify package was created
ls -la ./archive/
if [[ ! -f "./archive/${{ env.PLUGIN_NAME }}-package-${VERSION}.txz" ]]; then
echo "ERROR: Package not found!"
exit 1
fi
- name: Calculate hash
id: hash
run: |
VERSION="${{ steps.version.outputs.VERSION }}"
PACKAGE="./archive/${{ env.PLUGIN_NAME }}-package-${VERSION}.txz"
MD5=$(md5sum "$PACKAGE" | cut -d' ' -f1)
echo "MD5=${MD5}" >> $GITHUB_OUTPUT
echo "Package MD5: ${MD5}"
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: plugin-package
path: |
archive/*.txz
archive/release_info
retention-days: 30
release:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: main
token: ${{ secrets.GITHUB_TOKEN }}
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: plugin-package
path: artifacts/
- name: Prepare release notes
id: notes
run: |
VERSION="${{ needs.build.outputs.version }}"
# Read component versions from release_info
if [[ -f artifacts/release_info ]]; then
COMPONENTS=$(cat artifacts/release_info)
else
COMPONENTS="Compose v${{ env.COMPOSE_VERSION }}"
fi
# Create release body
cat > release_body.md << EOF
## Compose Manager v${VERSION}
### Installation
**Via Plugin Manager:**
\`\`\`
https://raw.githubusercontent.com/${{ github.repository }}/main/${{ env.PLUGIN_NAME }}.plg
\`\`\`
### Package Details
- **MD5:** \`${{ needs.build.outputs.md5 }}\`
### Components
${COMPONENTS}
EOF
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: "Compose Manager v${{ needs.build.outputs.version }}"
body_path: release_body.md
files: |
artifacts/*.txz
fail_on_unmatched_files: true
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update PLG in main branch
run: |
VERSION="${{ needs.build.outputs.version }}"
MD5="${{ needs.build.outputs.md5 }}"
# Configure git
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Update version and MD5 in PLG
sed -i \
-e "s|<!ENTITY version.*\".*\"|<!ENTITY version \"${VERSION}\"|" \
-e "s|<!ENTITY packageMD5.*\".*\"|<!ENTITY packageMD5 \"${MD5}\"|" \
${{ env.PLUGIN_NAME }}.plg
echo "Updated PLG file:"
head -20 ${{ env.PLUGIN_NAME }}.plg
# Commit and push
git add ${{ env.PLUGIN_NAME }}.plg
git commit -m "Release v${VERSION}" || echo "No changes to commit"
git push origin main