-
Notifications
You must be signed in to change notification settings - Fork 87
247 lines (213 loc) · 8.18 KB
/
publish-release.yml
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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
name: Publish Release
on:
workflow_dispatch:
inputs:
environment:
type: environment
required: true
description: Environment to publish packages to
jobs:
prepare-packages:
runs-on: ubuntu-latest
environment:
name: Staging
url: ${{ steps.upload-to-s3.outputs.url }}
name: Prepare packages
outputs:
version: ${{ steps.get-version.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: false
- name: Read version
id: get-version
run: |
pkgVersion=$(sed -ne "s/^version: \(.*\)/\1/p" packages/realm_dart/pubspec.yaml)
pkgSuffix="${{ github.event.inputs.environment != 'Production' && format('-{0}', github.sha) || '' }}"
echo "version=$pkgVersion$pkgSuffix" >> $GITHUB_OUTPUT
shell: bash
- name: Setup Runner
uses: ./.github/actions/setup-runner
- name: Download all artifacts
uses: dawidd6/action-download-artifact@71072fbb1229e1317f1a8de6b04206afb461bd67 # 3.1.2
with:
workflow: ci.yml
commit: ${{ github.sha }}
path: ${{ github.workspace }}/binary/
workflow_conclusion: completed
github_token: ${{ secrets.REALM_CI_PAT }}
# The rename is necessary because action-download-artifact will put things in a folder named the same
# as the artifact name - i.e. librealm-linux, etc.
- name: Archive binaries
run: |
mkdir -p ${{ github.workspace }}/release
for directory in ${{ github.workspace }}/binary/*; do
artifactFolder=$(basename $directory)
targetFile="${{ github.workspace }}/release/${artifactFolder#*-}.tar.gz"
dart run realm_dart archive --source-dir "$directory" --output-file "$targetFile"
done
working-directory: packages/realm_dart
shell: bash
- name: Update pubspec.yaml version (Staging)
if: ${{ github.event.inputs.environment != 'Production' }}
run: REALM_VERSION=${{ steps.get-version.outputs.version }} melos run update:version:realm
- name: Package realm_common
run: |
cp -Lr ../packages/realm_common .
cd realm_common
dart pub publish --dry-run || true
working-directory: release
- name: Package realm_generator
run: |
cp -Lr ../packages/realm_generator .
cd realm_generator
dart pub publish --dry-run || true
working-directory: release
# realm_flutter has symlinks to native binaries which should not be packaged
- name: Cleanup symlinks
run: |
rm packages/realm/android/src/main/cpp/lib
rm packages/realm/ios/realm_dart.xcframework
rm packages/realm/linux/binary
rm packages/realm/windows/binary
rm -rf packages/realm/tests/linux/flutter/ephemeral
rm -rf packages/realm/tests/windows/flutter/ephemeral
- name: Package realm (flutter)
run: |
cp -Lr ../packages/realm realm
cd realm
flutter pub publish --dry-run || true
working-directory: release
- name: Package realm_dart
run: |
mkdir realm_dart
cp -Lr ../packages/realm_dart/bin ../packages/realm_dart/example ../packages/realm_dart/lib ../packages/realm_dart/test realm_dart
rsync -vtL ../packages/realm_dart/* realm_dart/
cd realm_dart
dart pub publish --dry-run || true
working-directory: release
- name: Extract Changelog
run: |
$match = Get-Content ../CHANGELOG.md -Raw | select-string -pattern "(?ms)^(?<latestVersionChanges>.+?)(?=(\n|\r\n)## )"
$latestChanges = $match.Matches[0].Groups["latestVersionChanges"].Value;
$latestChanges | Out-File ExtractedChangelog.md
working-directory: release
shell: pwsh
- name: Upload release folder
uses: actions/upload-artifact@v4
with:
name: release-bundle
path: release/**
retention-days: 30
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_S3_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_S3_SECRET_KEY }}
aws-region: us-east-1
- name: Upload release folder to S3
id: upload-to-s3
run: |
tar -zcvf packages.tar.gz realm_common realm_generator realm_dart realm ExtractedChangelog.md
rm -rf common generator realm_dart realm ExtractedChangelog.md
s3_folder="static.realm.io/downloads/dart/${{ steps.get-version.outputs.version }}"
aws s3 sync --acl public-read . "s3://$s3_folder"
echo "url=https://$s3_folder/packages.tar.gz" >> $GITHUB_OUTPUT
working-directory: release
publish-packages:
runs-on: ubuntu-latest
if: ${{ github.event.inputs.environment == 'Production' }}
environment:
name: 'Production'
url: https://pub.dev/packages/realm/versions/${{ needs.prepare-packages.outputs.version }}
name: Publish release
needs:
- prepare-packages
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: false
- name: Download release folder
uses: actions/download-artifact@v4
with:
name: release-bundle
path: release
- name: Setup Runner
uses: ./.github/actions/setup-runner
# realm_flutter has symlinks to native binaries which should not be packaged
- name: Cleanup symlinks
run: |
rm packages/realm/android/src/main/cpp/lib
rm packages/realm/ios/realm_dart.xcframework
rm packages/realm/linux/binary
rm packages/realm/windows/binary
rm -rf packages/realm/tests/linux/flutter/ephemeral
rm -rf packages/realm/tests/windows/flutter/ephemeral
- name: Publish packages to pub.dev
run: |
mkdir -p $HOME/.config/dart
echo '${{ secrets.PUB_CREDENTIALS }}' >> $HOME/.config/dart/pub-credentials.json
melos exec --no-published --no-private -- dart pub publish --force --skip-validation
- name: Reset repo state
run: git reset --hard
- name: Find Release PR
uses: juliangruber/find-pull-request-action@f9f7484f8237cf8485e5ab826e542ba5dd9e9c6e
id: find-pull-request
with:
branch: ${{ github.ref }}
- name: Merge Pull Request
uses: juliangruber/merge-pull-request-action@8a13f2645ad8b6ada32f829b2fae9c0955a5265d
with:
github-token: ${{ secrets.REALM_CI_PAT }}
number: ${{ steps.find-pull-request.outputs.number }}
method: squash
- name: Publish Github Release
uses: ncipollo/release-action@10c84d509b28aae3903113151bfd832314964f2e
with:
bodyFile: release/ExtractedChangelog.md
name: ${{ needs.prepare-packages.outputs.version }}
commit: main
tag: ${{ needs.prepare-packages.outputs.version }}
token: ${{ secrets.REALM_CI_PAT }}
draft: false
- name: 'Post to #appx-releases'
uses: realm/ci-actions/release-to-slack@338bf3e7575015a28faec8b67614385d122aece7
continue-on-error: true
with:
changelog: release/ExtractedChangelog.md
sdk: Flutter/Dart
webhook-url: ${{ secrets.SLACK_RELEASES_WEBHOOK }}
version: ${{ needs.prepare-packages.outputs.version }}
- name: Update Changelog
run: |
echo "## vNext (TBD)
### Enhancements
* None
### Fixed
* None
### Compatibility
* Realm Studio: 15.0.0 or later.
### Internal
* Using Core x.y.z.
" | cat - CHANGELOG.md >> temp
mv temp CHANGELOG.md
shell: bash
- name: Add vNext Changelog header
id: vnext-pr
uses: peter-evans/create-pull-request@7380612b49221684fefa025244f2ef4008ae50ad
with:
branch: vnext-changelog
title: Add vNext Changelog header
body: Update Changelog for vNext
labels: no-jira-ticket
delete-branch: true
base: main
commit-message: Add vNext Changelog header
- name: Merge Pull Request
uses: juliangruber/merge-pull-request-action@8a13f2645ad8b6ada32f829b2fae9c0955a5265d
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
number: ${{ steps.vnext-pr.outputs.pull-request-number }}
method: squash