Skip to content

Commit de4c048

Browse files
authored
autoincrement correctly, don't use /latest links for internal notif, fix broken links (#8407)
1 parent 2c4ba90 commit de4c048

2 files changed

Lines changed: 47 additions & 30 deletions

File tree

.github/workflows/nightly.yml

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,25 @@ jobs:
3636
run_ios: ${{ steps.platforms.outputs.run_ios }}
3737
steps:
3838
- uses: actions/checkout@v4
39+
with:
40+
fetch-depth: 0
41+
fetch-tags: true
3942

4043
- id: meta
4144
shell: bash
4245
env:
4346
GH_TOKEN: ${{ github.token }}
4447
run: |
45-
RELEASE_LATEST=$(gh release list --json tagName -q=".[0].tagName")
46-
echo "version release (latest): $RELEASE_LATEST"
48+
TAG_LATEST=$(git describe --tags --abbrev=0)
49+
echo "version tag (latest): $TAG_LATEST"
4750
48-
RELEASE_BASE=$(echo "$RELEASE_LATEST" | awk -F'-' '{print $1}')
51+
RELEASE_BASE=$(echo "$TAG_LATEST" | awk -F'-' '{print $1}')
4952
echo "version base (current): $RELEASE_BASE"
5053
51-
# increment the patch of the latest release by 1
54+
# increment the patch of the latest tag by 1
5255
RELEASE_BASE_NEXT=$(echo "$RELEASE_BASE" | awk -F'\\.' -v OFS='.' '{ $NF = $NF + 1; print }')
5356
echo "version base (next): $RELEASE_BASE_NEXT"
5457
55-
# hardcoded for now so that the 9.0.0 release does not appear to be behind a nightly
56-
RELEASE_BASE_NEXT="v9.0.0" # TODO: remove after "v9.0.0" release and allow to increment naturally
57-
5858
DATE=$(date -u +%Y%m%dT%H%M%SZ) # ISO 8601 without colons or dashes
5959
REF=$(git rev-parse --short HEAD)
6060
VER="${RELEASE_BASE_NEXT}-${REF}-${DATE}"
@@ -172,7 +172,7 @@ jobs:
172172
runs-on: ubuntu-latest
173173
env:
174174
INSTALLER_NAME: ${{ needs.set-nightly-metadata.outputs.installer_name }}
175-
BUCKET: ${{ secrets.S3_RELEASES_BUCKET }}
175+
BUCKET: ${{ vars.S3_RELEASES_BUCKET }}
176176
RUN_MACOS: ${{ needs.set-nightly-metadata.outputs.run_macos }}
177177
RUN_WINDOWS: ${{ needs.set-nightly-metadata.outputs.run_windows }}
178178
RUN_ANDROID: ${{ needs.set-nightly-metadata.outputs.run_android }}
@@ -191,31 +191,29 @@ jobs:
191191
sha="$(git rev-parse --short HEAD)"
192192
193193
cat > release_notes.md <<EOF
194-
## Nightly Build
195194
196195
This is an automated nightly build from commit \`$sha\`.
197196
198197
**Branch:** \`${{ github.ref_name }}\`
199-
**Build Date:** $(date -u +"%Y-%m-%d %H:%M:%S UTC")
200-
201-
### Downloads
202198
EOF
203199
204200
if [[ "$RUN_MACOS" == "true" ]]; then
205-
echo "- macOS: \`${INSTALLER_NAME}.dmg\`" >> release_notes.md
201+
echo "- macOS: https://$BUCKET.s3.amazonaws.com/nightly/${sha}/${INSTALLER_NAME}.dmg" >> release_notes.md
206202
fi
207203
if [[ "$RUN_WINDOWS" == "true" ]]; then
208-
echo "- Windows: \`${INSTALLER_NAME}.exe\`" >> release_notes.md
204+
echo "- Windows: https://$BUCKET.s3.amazonaws.com/nightly/${sha}/${INSTALLER_NAME}.exe" >> release_notes.md
209205
fi
210206
if [[ "$RUN_ANDROID" == "true" ]]; then
211-
echo "- Android: \`${INSTALLER_NAME}.apk\`" >> release_notes.md
207+
echo "- Android: https://$BUCKET.s3.amazonaws.com/nightly/${sha}/${INSTALLER_NAME}.apk" >> release_notes.md
212208
fi
213209
if [[ "$RUN_LINUX" == "true" ]]; then
214-
echo "- Linux: \`${INSTALLER_NAME}.deb\`, \`${INSTALLER_NAME}.rpm\`" >> release_notes.md
210+
echo "- Linux (.deb): https://$BUCKET.s3.amazonaws.com/nightly/${sha}/${INSTALLER_NAME}.deb" >> release_notes.md
211+
echo "- Linux (.rpm): https://$BUCKET.s3.amazonaws.com/nightly/${sha}/${INSTALLER_NAME}.rpm" >> release_notes.md
215212
fi
216213
217214
# Create the pre-release as a draft, because immutable releases
218215
# forbid uploading artifacts after publication.
216+
# Subsequent steps may either delete this or publish it.
219217
gh release create "$VERSION" \
220218
--draft \
221219
--prerelease \
@@ -326,17 +324,17 @@ jobs:
326324
{
327325
echo "## Nightly links (commit \`$sha\`)"
328326
if [[ "$RUN_MACOS" == "true" ]]; then
329-
echo "- macOS: https://$BUCKET.s3.amazonaws.com/nightly/latest/${INSTALLER_NAME}.dmg"
327+
echo "- macOS: https://$BUCKET.s3.amazonaws.com/nightly/${sha}/${INSTALLER_NAME}.dmg"
330328
fi
331329
if [[ "$RUN_WINDOWS" == "true" ]]; then
332-
echo "- Windows: https://$BUCKET.s3.amazonaws.com/nightly/latest/${INSTALLER_NAME}.exe"
330+
echo "- Windows: https://$BUCKET.s3.amazonaws.com/nightly/${sha}/${INSTALLER_NAME}.exe"
333331
fi
334332
if [[ "$RUN_ANDROID" == "true" ]]; then
335-
echo "- Android: https://$BUCKET.s3.amazonaws.com/nightly/latest/${INSTALLER_NAME}.apk"
333+
echo "- Android: https://$BUCKET.s3.amazonaws.com/nightly/${sha}/${INSTALLER_NAME}.apk"
336334
fi
337335
if [[ "$RUN_LINUX" == "true" ]]; then
338-
echo "- Linux DEB: https://$BUCKET.s3.amazonaws.com/nightly/latest/${INSTALLER_NAME}.deb"
339-
echo "- Linux RPM: https://$BUCKET.s3.amazonaws.com/nightly/latest/${INSTALLER_NAME}.rpm"
336+
echo "- Linux DEB: https://$BUCKET.s3.amazonaws.com/nightly/${sha}/${INSTALLER_NAME}.deb"
337+
echo "- Linux RPM: https://$BUCKET.s3.amazonaws.com/nightly/${sha}/${INSTALLER_NAME}.rpm"
340338
fi
341339
} >> "$GITHUB_STEP_SUMMARY"
342340
@@ -345,20 +343,21 @@ jobs:
345343
id: slack_msg
346344
run: |
347345
sha="$(git rev-parse --short HEAD)"
348-
text="Lantern nightly '${{ needs.set-nightly-metadata.outputs.version }}' is ready.\n*Branch:* '${{ github.ref_name }}'\n*Downloads:*"
346+
version="${{ needs.set-nightly-metadata.outputs.version }}"
347+
text="Lantern nightly <https://github.com/getlantern/lantern/releases/tag/$version|$version> is ready.\n*Branch:* '${{ github.ref_name }}'\n*Downloads:*"
349348
350349
if [[ "$RUN_MACOS" == "true" ]]; then
351-
text="${text}\n• <https://${BUCKET}.s3.amazonaws.com/nightly/latest/${INSTALLER_NAME}.dmg|macOS>"
350+
text="${text}\n• <https://${BUCKET}.s3.amazonaws.com/nightly/${sha}/${INSTALLER_NAME}.dmg|macOS>"
352351
fi
353352
if [[ "$RUN_WINDOWS" == "true" ]]; then
354-
text="${text}\n• <https://${BUCKET}.s3.amazonaws.com/nightly/latest/${INSTALLER_NAME}.exe|Windows>"
353+
text="${text}\n• <https://${BUCKET}.s3.amazonaws.com/nightly/${sha}/${INSTALLER_NAME}.exe|Windows>"
355354
fi
356355
if [[ "$RUN_ANDROID" == "true" ]]; then
357-
text="${text}\n• <https://${BUCKET}.s3.amazonaws.com/nightly/latest/${INSTALLER_NAME}.apk|Android>"
356+
text="${text}\n• <https://${BUCKET}.s3.amazonaws.com/nightly/${sha}/${INSTALLER_NAME}.apk|Android>"
358357
fi
359358
if [[ "$RUN_LINUX" == "true" ]]; then
360-
text="${text}\n• <https://${BUCKET}.s3.amazonaws.com/nightly/latest/${INSTALLER_NAME}.deb|Linux (.deb)>"
361-
text="${text}\n• <https://${BUCKET}.s3.amazonaws.com/nightly/latest/${INSTALLER_NAME}.rpm|Linux (.rpm)>"
359+
text="${text}\n• <https://${BUCKET}.s3.amazonaws.com/nightly/${sha}/${INSTALLER_NAME}.deb|Linux (.deb)>"
360+
text="${text}\n• <https://${BUCKET}.s3.amazonaws.com/nightly/${sha}/${INSTALLER_NAME}.rpm|Linux (.rpm)>"
362361
fi
363362
364363
# Expose as output

.github/workflows/release.yml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ jobs:
187187
env:
188188
BUILD_TYPE: ${{ needs.set-release-metadata.outputs.build_type }}
189189
INSTALLER_NAME: ${{ needs.set-release-metadata.outputs.installer_name }}
190-
BUCKET: ${{ secrets.S3_RELEASES_BUCKET }}
190+
BUCKET: ${{ vars.S3_RELEASES_BUCKET }}
191191
RELEASE_TAG: ${{ github.ref_name }}
192192
S3_TAG: ${{ needs.set-release-metadata.outputs.tag_base }}
193193
steps:
@@ -284,22 +284,40 @@ jobs:
284284
git add appcast.xml
285285
git commit -m "Update appcast.xml" || echo "No changes to commit"
286286
git push
287-
bucket="${{ secrets.S3_RELEASES_BUCKET }}"
287+
bucket="${{ vars.S3_RELEASES_BUCKET }}"
288288
289289
aws s3 cp appcast.xml "s3://${bucket}/releases/${{ env.BUILD_TYPE }}/latest/appcast.xml" --acl public-read
290290
291291
if [[ "${{ env.BUILD_TYPE }}" == "production" ]]; then
292292
aws s3 cp appcast.xml "s3://${bucket}/releases/appcast.xml" --acl public-read
293293
fi
294294
295+
- name: Build Slack message
296+
id: slack_msg
297+
run: |
298+
prefix="releases/${BUILD_TYPE}"
299+
tag="${RELEASE_TAG}"
300+
s3_tag="${S3_TAG:-$tag}"
301+
text="Lantern ${BUILD_TYPE} <https://github.com/getlantern/lantern/releases/tag/$tag|$tag}}> is released!\n*Branch:* '${{ github.ref_name }}'\n*Downloads:*"
302+
text="${text}\n• <https://${BUCKET}.s3.amazonaws.com/${prefix}/${s3_tag}/${INSTALLER_NAME}.dmg|macOS>"
303+
text="${text}\n• <https://${BUCKET}.s3.amazonaws.com/${prefix}/${s3_tag}/${INSTALLER_NAME}.exe|Windows>"
304+
text="${text}\n• <https://${BUCKET}.s3.amazonaws.com/${prefix}/${s3_tag}/${INSTALLER_NAME}.apk|Android>"
305+
text="${text}\n• <https://${BUCKET}.s3.amazonaws.com/${prefix}/${s3_tag}/${INSTALLER_NAME}.deb|Linux (.deb)>"
306+
text="${text}\n• <https://${BUCKET}.s3.amazonaws.com/${prefix}/${s3_tag}/${INSTALLER_NAME}.rpm|Linux (.rpm)>"
307+
308+
# Expose as output
309+
echo "text<<EOF" >> "$GITHUB_OUTPUT"
310+
echo "$text" >> "$GITHUB_OUTPUT"
311+
echo "EOF" >> "$GITHUB_OUTPUT"
312+
295313
- name: Notify Slack
296314
uses: slackapi/slack-github-action@v2.0.0
297315
with:
298316
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
299317
webhook-type: webhook-trigger
300318
payload: |
301319
{
302-
"text": "Lantern ${{ env.BUILD_TYPE }} ${{ github.ref_name }} released!*\n*Latest downloads:*\n• <https://${{ env.BUCKET }}.s3.amazonaws.com/releases/${{ env.BUILD_TYPE }}/latest/${{ env.INSTALLER_NAME }}.dmg|macOS>\n• <https://${{ env.BUCKET }}.s3.amazonaws.com/releases/${{ env.BUILD_TYPE }}/latest/${{ env.INSTALLER_NAME }}.exe|Windows>\n• <https://${{ env.BUCKET }}.s3.amazonaws.com/releases/${{ env.BUILD_TYPE }}/latest/${{ env.INSTALLER_NAME }}.apk|Android>\n• <https://${{ env.BUCKET }}.s3.amazonaws.com/releases/${{ env.BUILD_TYPE }}/latest/${{ env.INSTALLER_NAME }}.deb|Linux (.deb)>\n• <https://${{ env.BUCKET }}.s3.amazonaws.com/releases/${{ env.BUILD_TYPE }}/latest/${{ env.INSTALLER_NAME }}.rpm|Linux (.rpm)>\n\n*Tag-scoped:* <https://${{ env.BUCKET }}.s3.amazonaws.com/releases/${{ env.BUILD_TYPE }}/${{ github.ref_name }}/|releases/${{ env.BUILD_TYPE }}/${{ github.ref_name }}/>"
320+
"text": "${{ steps.slack_msg.outputs.text }}"
303321
}
304322
env:
305323
INSTALLER_NAME: ${{ needs.set-release-metadata.outputs.installer_name }}

0 commit comments

Comments
 (0)