-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodules-artifact-generation.yml
More file actions
217 lines (201 loc) · 8.55 KB
/
modules-artifact-generation.yml
File metadata and controls
217 lines (201 loc) · 8.55 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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
name: 📦 Module | Artifact Generation
on:
workflow_call:
inputs:
artifact-types:
description: 'Types of artifacts to generate (source, binaries, docker, all)'
required: false
type: string
default: 'source'
tag-name:
description: 'Git tag name for the artifacts'
required: true
type: string
version:
description: 'Version string for the artifacts'
required: true
type: string
release-url:
description: 'Release URL to upload artifacts to'
required: false
type: string
default: ''
build-command:
description: 'Custom build command for binaries'
required: false
type: string
default: ''
docker-registry:
description: 'Docker registry for image publishing'
required: false
type: string
default: 'ghcr.io'
runs-on:
description: 'Runner to use. Use string for GitHub-hosted (e.g., "ubuntu-latest") or JSON array for self-hosted (e.g., ["self-hosted", "linux"])'
required: false
type: string
default: 'ubuntu-latest'
secrets:
DOCKER_USERNAME:
description: 'Docker registry username'
required: false
DOCKER_PASSWORD:
description: 'Docker registry password/token'
required: false
outputs:
artifacts-generated:
description: 'Whether artifacts were generated successfully'
value: ${{ jobs.generate-artifacts.outputs.artifacts-generated }}
source-archive-created:
description: 'Whether source archive was created'
value: ${{ jobs.generate-artifacts.outputs.source-archive-created }}
binaries-created:
description: 'Whether binaries were created'
value: ${{ jobs.generate-artifacts.outputs.binaries-created }}
docker-image-pushed:
description: 'Whether Docker image was pushed'
value: ${{ jobs.generate-artifacts.outputs.docker-image-pushed }}
permissions:
contents: write
packages: write
actions: read
jobs:
generate-artifacts:
name: 🔧 Artifact Creation
runs-on: ${{ startsWith(inputs.runs-on, '[') && fromJSON(inputs.runs-on) || inputs.runs-on }}
outputs:
artifacts-generated: ${{ steps.summary.outputs.artifacts-generated }}
source-archive-created: ${{ steps.artifacts.outputs.source-archive-created }}
binaries-created: ${{ steps.artifacts.outputs.binaries-created }}
docker-image-pushed: ${{ steps.artifacts.outputs.docker-image-pushed }}
steps:
- name: 🚀 Checkout Repository
uses: actions/checkout@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: 🔨 Generate Artifacts
id: artifacts
uses: bauer-group/automation-templates/.github/actions/artifact-generator@main
with:
artifact-types: ${{ inputs.artifact-types }}
tag-name: ${{ inputs.tag-name }}
version: ${{ inputs.version }}
upload-url: ${{ inputs.release-url }}
build-command: ${{ inputs.build-command }}
docker-registry: ${{ inputs.docker-registry }}
docker-username: ${{ secrets.DOCKER_USERNAME || github.actor }}
docker-password: ${{ secrets.DOCKER_PASSWORD || secrets.GITHUB_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: 📊 Artifact Generation Summary
id: summary
if: always()
run: |
# Determine if artifacts were successfully generated
SOURCE_OK="${{ steps.artifacts.outputs.source-archive-created }}"
BINARIES_OK="${{ steps.artifacts.outputs.binaries-created }}"
DOCKER_OK="${{ steps.artifacts.outputs.docker-image-pushed }}"
# Consider successful if at least one artifact type was requested and created
ARTIFACTS_GENERATED="false"
case "${{ inputs.artifact-types }}" in
"source")
if [ "$SOURCE_OK" = "true" ]; then
ARTIFACTS_GENERATED="true"
fi
;;
"binaries")
if [ "$BINARIES_OK" = "true" ]; then
ARTIFACTS_GENERATED="true"
fi
;;
"docker")
if [ "$DOCKER_OK" = "true" ]; then
ARTIFACTS_GENERATED="true"
fi
;;
"all")
if [ "$SOURCE_OK" = "true" ] || [ "$BINARIES_OK" = "true" ] || [ "$DOCKER_OK" = "true" ]; then
ARTIFACTS_GENERATED="true"
fi
;;
esac
echo "artifacts-generated=$ARTIFACTS_GENERATED" >> $GITHUB_OUTPUT
# Generate summary report
echo "### 🔨 Artifact Generation Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Configuration | Value |" >> $GITHUB_STEP_SUMMARY
echo "|---------------|-------|" >> $GITHUB_STEP_SUMMARY
echo "| **Artifact Types** | ${{ inputs.artifact-types }} |" >> $GITHUB_STEP_SUMMARY
echo "| **Version** | ${{ inputs.version }} |" >> $GITHUB_STEP_SUMMARY
echo "| **Tag** | ${{ inputs.tag-name }} |" >> $GITHUB_STEP_SUMMARY
echo "| **Docker Registry** | ${{ inputs.docker-registry }} |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "#### 📋 Generation Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Artifact Type | Status |" >> $GITHUB_STEP_SUMMARY
echo "|---------------|--------|" >> $GITHUB_STEP_SUMMARY
# Source Archive Status
if [[ '${{ inputs.artifact-types }}' =~ (source|all) ]]; then
if [ "$SOURCE_OK" = "true" ]; then
echo "| **Source Archive** | ✅ Created |" >> $GITHUB_STEP_SUMMARY
else
echo "| **Source Archive** | ❌ Failed |" >> $GITHUB_STEP_SUMMARY
fi
else
echo "| **Source Archive** | ⏭️ Skipped |" >> $GITHUB_STEP_SUMMARY
fi
# Binaries Status
if [[ '${{ inputs.artifact-types }}' =~ (binaries|all) ]]; then
if [ "$BINARIES_OK" = "true" ]; then
echo "| **Binaries** | ✅ Created |" >> $GITHUB_STEP_SUMMARY
else
echo "| **Binaries** | ❌ Failed |" >> $GITHUB_STEP_SUMMARY
fi
else
echo "| **Binaries** | ⏭️ Skipped |" >> $GITHUB_STEP_SUMMARY
fi
# Docker Image Status
if [[ '${{ inputs.artifact-types }}' =~ (docker|all) ]]; then
if [ "$DOCKER_OK" = "true" ]; then
echo "| **Docker Image** | ✅ Pushed |" >> $GITHUB_STEP_SUMMARY
else
echo "| **Docker Image** | ❌ Failed |" >> $GITHUB_STEP_SUMMARY
fi
else
echo "| **Docker Image** | ⏭️ Skipped |" >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
if [ "$ARTIFACTS_GENERATED" = "true" ]; then
echo "✅ **Artifact generation completed successfully!**" >> $GITHUB_STEP_SUMMARY
if [ "${{ inputs.release-url }}" != "" ]; then
echo "" >> $GITHUB_STEP_SUMMARY
echo "📦 **Artifacts uploaded to release:** [View Release](${{ inputs.release-url }})" >> $GITHUB_STEP_SUMMARY
fi
if [[ "${{ inputs.artifact-types }}" =~ (docker|all) ]] && [ "$DOCKER_OK" = "true" ]; then
IMAGE_NAME="${{ github.repository }}"
echo "🐳 **Docker Image:** \`${{ inputs.docker-registry }}/${IMAGE_NAME}:${{ inputs.version }}\`" >> $GITHUB_STEP_SUMMARY
fi
else
echo "❌ **Artifact generation failed or no artifacts were created.**" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Troubleshooting:**" >> $GITHUB_STEP_SUMMARY
echo "- Check build commands and dependencies" >> $GITHUB_STEP_SUMMARY
echo "- Verify Docker registry credentials" >> $GITHUB_STEP_SUMMARY
echo "- Review artifact generation logs" >> $GITHUB_STEP_SUMMARY
fi
- name: 📤 Upload Additional Build Artifacts
if: always()
uses: actions/upload-artifact@v6
with:
name: additional-artifacts-${{ inputs.version }}
path: |
dist/
build/
target/
out/
*.vsix
*.nupkg
*.apk
*.ipa
if-no-files-found: ignore
retention-days: 90