66 - " **"
77 workflow_dispatch :
88 inputs :
9+ release_version :
10+ description : " Release version (e.g., v1.0.0 - leave empty for auto-increment)"
11+ required : false
12+ type : string
913 wildduck_version :
1014 description : " Wildduck version (leave empty for latest)"
1115 required : false
2024 type : string
2125
2226jobs :
27+ determine-version :
28+ if : github.event_name == 'workflow_dispatch'
29+ runs-on : ubuntu-latest
30+ outputs :
31+ version : ${{ steps.set_version.outputs.version }}
32+ steps :
33+ - name : Determine release version
34+ id : set_version
35+ run : |
36+ if [ -n "${{ inputs.release_version }}" ]; then
37+ # Use provided version
38+ VERSION="${{ inputs.release_version }}"
39+
40+ # Check if tag already exists
41+ if git ls-remote --tags origin | grep -q "refs/tags/$VERSION"; then
42+ echo "❌ Error: Tag $VERSION already exists"
43+ exit 1
44+ fi
45+
46+ echo "Using manual version: $VERSION"
47+ echo "version=$VERSION" >> $GITHUB_OUTPUT
48+ else
49+ # Get latest release and increment patch version
50+ LATEST_RELEASE=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest \
51+ | jq -r '.tag_name')
52+
53+ if [ -z "$LATEST_RELEASE" ] || [ "$LATEST_RELEASE" = "null" ]; then
54+ # No releases yet, start with v1.0.0-dispatch
55+ NEW_VERSION="v1.0.0-dispatch"
56+ else
57+ # Remove 'v' prefix and any existing suffix
58+ BASE_VERSION=$(echo "$LATEST_RELEASE" | sed 's/^v//' | sed 's/-dispatch$//')
59+
60+ # Split version into components
61+ IFS='.' read -r MAJOR MINOR PATCH <<< "$BASE_VERSION"
62+
63+ # Increment patch version
64+ PATCH=$((PATCH + 1))
65+
66+ # Create new version with -dispatch suffix
67+ NEW_VERSION="v${MAJOR}.${MINOR}.${PATCH}-dispatch"
68+ fi
69+
70+ echo "Auto-generated version: $NEW_VERSION"
71+ echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
72+ fi
73+
2374 build :
75+ needs : [determine-version]
76+ if : always() && (github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && needs.determine-version.result == 'success'))
2477 runs-on : ubuntu-latest
2578 strategy :
2679 matrix :
@@ -136,19 +189,42 @@ jobs:
136189 ${{ matrix.project.name }}-${{ steps.get_version.outputs.tag }}.tar.gz
137190
138191 create-release :
139- needs : build
192+ needs : [determine-version, build]
193+ if : always() && needs.build.result == 'success'
140194 runs-on : ubuntu-latest
141195 permissions :
142196 contents : write
143197 steps :
198+ - name : Checkout repository
199+ uses : actions/checkout@v6
200+ if : github.event_name == 'workflow_dispatch'
201+
144202 - name : Download all artifacts
145203 uses : actions/download-artifact@v6
146204 with :
147205 path : artifacts
148206
207+ - name : Get release version
208+ id : get_release_version
209+ run : |
210+ if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
211+ echo "version=${{ needs.determine-version.outputs.version }}" >> $GITHUB_OUTPUT
212+ else
213+ echo "version=${{ github.ref_name }}" >> $GITHUB_OUTPUT
214+ fi
215+
216+ - name : Create tag for workflow_dispatch
217+ if : github.event_name == 'workflow_dispatch'
218+ run : |
219+ git config user.name "github-actions[bot]"
220+ git config user.email "github-actions[bot]@users.noreply.github.com"
221+ git tag ${{ steps.get_release_version.outputs.version }}
222+ git push origin ${{ steps.get_release_version.outputs.version }}
223+
149224 - name : Create Release
150225 uses : softprops/action-gh-release@v2
151226 with :
227+ tag_name : ${{ steps.get_release_version.outputs.version }}
152228 files : |
153229 artifacts/*/*.zip
154230 artifacts/*/*.tar.gz
@@ -158,6 +234,8 @@ jobs:
158234 body : |
159235 ## Mail Server Stack Build
160236
237+ **Trigger:** ${{ github.event_name == 'workflow_dispatch' && 'Manual Dispatch' || 'Tag Push' }}
238+
161239 This release includes:
162240 - Wildduck
163241 - Zone-MTA
0 commit comments