forked from leoafarias/fvm
-
Notifications
You must be signed in to change notification settings - Fork 0
232 lines (193 loc) · 7.5 KB
/
release.yml
File metadata and controls
232 lines (193 loc) · 7.5 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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
name: Deploy Release
on:
release:
types: [published]
# Manual trigger for testing
workflow_dispatch:
inputs:
release_tag:
description: 'Release tag to deploy (e.g., v4.0.0-beta.2)'
required: true
env:
PUB_CREDENTIALS: ${{ secrets.PUB_CREDENTIALS }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
prepare-release:
name: Prepare Release
runs-on: ubuntu-latest
outputs:
version: ${{ steps.extract-version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Extract version from release or input
id: extract-version
run: |
if [[ "${{ github.event_name }}" == "release" ]]; then
VERSION="${{ github.event.release.tag_name }}"
else
VERSION="${{ github.event.inputs.release_tag }}"
fi
# Remove 'v' prefix if present
VERSION=${VERSION#v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
echo "🚀 Preparing release for version: $VERSION"
- name: Update pubspec.yaml version
run: |
echo "📝 Updating pubspec.yaml version to $RELEASE_VERSION"
sed -i "s/^version: .*/version: $RELEASE_VERSION/" pubspec.yaml
echo "✅ Updated version:"
grep "^version:" pubspec.yaml
- name: Prepare environment
uses: ./.github/actions/prepare
- name: Generate version.dart
run: |
echo "🔨 Generating version.dart with build_runner"
dart run build_runner build --delete-conflicting-outputs
echo "✅ Generated version.dart content:"
cat lib/src/version.dart
- name: Update CHANGELOG with release link
run: |
echo "📝 Adding $RELEASE_VERSION entry to CHANGELOG.md"
TODAY=$(date +%Y-%m-%d)
awk -v version="$RELEASE_VERSION" -v date="$TODAY" '
/^## \[Unreleased\]/ {
print; print "";
print "## [" version "] - " date; print "";
print "See [Release Notes](https://github.com/leoafarias/fvm/releases/tag/v" version ")"; print "";
next
} 1' CHANGELOG.md > temp_changelog && mv temp_changelog CHANGELOG.md
echo "✅ Added $RELEASE_VERSION to CHANGELOG.md"
echo "📋 CHANGELOG.md preview:"
head -12 CHANGELOG.md
- name: Commit version updates locally
run: |
echo "📝 Committing version updates and generated files locally"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add pubspec.yaml lib/src/version.dart CHANGELOG.md
find lib -name "*.mapper.dart" -exec git add {} ;
git commit -m "chore: update version to $RELEASE_VERSION for release" || echo "No changes to commit"
echo "✅ Changes committed locally"
- name: Validate pub.dev package (dry run)
run: |
echo "🔍 Validating package for pub.dev..."
dart pub publish --dry-run
echo "✅ Package validation successful!"
- name: Push version updates to main
run: |
echo "📤 Pushing version updates to main branch"
git push origin main
echo "✅ Changes pushed to main branch"
test:
name: Test
needs: prepare-release
uses: ./.github/workflows/test.yml
deploy:
name: Deploy Core
needs: [prepare-release, test]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set version from prepare-release
run: |
VERSION="${{ needs.prepare-release.outputs.version }}"
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
echo "🚀 Deploying version: $VERSION"
- name: Prepare environment
uses: ./.github/actions/prepare
- name: Generate code with build_runner
run: dart run build_runner build --delete-conflicting-outputs
# Skip pkg-github-release - release already exists
- name: Deploy Linux binaries to existing release
run: dart run grinder pkg-github-linux
- name: Deploy to Pub
run: dart run grinder pkg-pub-deploy
deploy-windows:
name: Deploy Windows
runs-on: windows-latest
needs: [prepare-release, test]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CHOCOLATEY_TOKEN: ${{ secrets.CHOCOLATEY_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set version from prepare-release
run: |
$VERSION = "${{ needs.prepare-release.outputs.version }}"
echo "RELEASE_VERSION=$VERSION" | Out-File -FilePath $env:GITHUB_ENV -Append
echo "🔄 Deploying Windows for version: $VERSION"
- name: Prepare environment
uses: ./.github/actions/prepare
- name: Generate code with build_runner
run: dart run build_runner build --delete-conflicting-outputs
- name: Deploy Windows binaries to existing release
run: dart run grinder pkg-github-windows
- name: Deploy Chocolatey
run: dart run grinder pkg-chocolatey-deploy
deploy-macos:
name: Deploy macOS
runs-on: macos-latest
needs: [prepare-release, test]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set version from prepare-release
run: |
VERSION="${{ needs.prepare-release.outputs.version }}"
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
echo "🔄 Deploying macOS for version: $VERSION"
- name: Prepare environment
uses: ./.github/actions/prepare
- name: Generate code with build_runner
run: dart run build_runner build --delete-conflicting-outputs
- name: Deploy macOS binaries to existing release
run: dart run grinder pkg-github-macos
- name: Deploy versioned Homebrew formula
run: dart run grinder pkg-homebrew-update --versioned-formula
env:
GITHUB_TOKEN: ${{ secrets.HOMEBREW_FVM_GH_TOKEN }}
- name: Deploy Homebrew
run: dart run grinder pkg-homebrew-update
env:
GITHUB_TOKEN: ${{ secrets.HOMEBREW_FVM_GH_TOKEN }}
deploy-docker:
name: Deploy Docker
runs-on: ubuntu-latest
needs: [prepare-release, test]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set version for Docker
run: |
VERSION="${{ needs.prepare-release.outputs.version }}"
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
echo "🐳 Building Docker image for version: $VERSION"
- name: Prepare environment
uses: ./.github/actions/prepare
- name: Generate code with build_runner
run: dart run build_runner build --delete-conflicting-outputs
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
file: ./.docker/Dockerfile
push: true
tags: leoafarias/fvm:${{ env.RELEASE_VERSION }}
build-args: |
FVM_VERSION=${{ env.RELEASE_VERSION }}