-
Notifications
You must be signed in to change notification settings - Fork 0
149 lines (122 loc) · 4.98 KB
/
release.yml
File metadata and controls
149 lines (122 loc) · 4.98 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
name: Release
on:
push:
tags:
- "v*.*.*" # Triggers on version tags like v1.0.0, v0.1.0, etc.
permissions:
contents: write
packages: write
id-token: write
attestations: write
jobs:
release:
name: Build and Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Cache Go modules
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Extract version from tag
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Releasing version: $VERSION"
- name: Build and push multi-platform container images
run: |
# Convert to lowercase (GHCR requirement)
OWNER_LC=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
export IMG=ghcr.io/${OWNER_LC}/folder-controller:${{ steps.version.outputs.version }}
export IMG_LATEST=ghcr.io/${OWNER_LC}/folder-controller:latest
# Build and push with version tag
make docker-buildx IMG=$IMG
# Also tag as latest
docker buildx imagetools create $IMG --tag $IMG_LATEST
- name: Generate installable manifest
run: |
# Convert to lowercase (GHCR requirement)
OWNER_LC=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
export IMG=ghcr.io/${OWNER_LC}/folder-controller:${{ steps.version.outputs.version }}
make build-installer
- name: Verify manifest was created
run: |
if [ ! -f dist/install.yaml ]; then
echo "Error: dist/install.yaml was not created"
exit 1
fi
echo "Manifest size: $(wc -c < dist/install.yaml) bytes"
echo "Manifest preview (first 50 lines):"
head -n 50 dist/install.yaml
- name: Create Release Notes
id: release_notes
run: |
# Convert to lowercase (GHCR requirement)
OWNER_LC=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
cat > release_notes.md << EOF
## Folder Controller ${{ steps.version.outputs.version }}
### Installation
Install the Folder controller using the provided manifest:
\`\`\`bash
kubectl apply -f https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.version }}/install.yaml
\`\`\`
### Container Images
Multi-platform container images are available at:
- \`ghcr.io/${OWNER_LC}/folder-controller:${{ steps.version.outputs.version }}\`
- \`ghcr.io/${OWNER_LC}/folder-controller:latest\`
Supported architectures:
- linux/amd64
- linux/arm64
- linux/s390x
- linux/ppc64le
### What's Changed
<!-- Add your changelog here or auto-generate it -->
**Full Changelog**: https://github.com/${{ github.repository }}/compare/v0.0.0...${{ steps.version.outputs.version }}
EOF
cat release_notes.md
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: |
dist/install.yaml
body_path: release_notes.md
draft: false
prerelease: false
generate_release_notes: true
env:
GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }}
- name: Summary
run: |
# Convert to lowercase (GHCR requirement)
OWNER_LC=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
echo "## Release Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "✅ **Version**: ${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "✅ **Container Image**: ghcr.io/${OWNER_LC}/folder-controller:${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "✅ **Installable Manifest**: Attached to release" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Installation Command" >> $GITHUB_STEP_SUMMARY
echo '```bash' >> $GITHUB_STEP_SUMMARY
echo "kubectl apply -f https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.version }}/install.yaml" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY