Skip to content

Commit 69f3058

Browse files
committed
ci: publish prerelease on push to master, feature/x
Problem: - Artifacts for `master` branch and `feature/x` branches are not published to a canonical location, which makes it difficult for scripts to consume them. - Artifacts from `feature/x` branches are not advertised in GitHub's "release" UI. - Per-commit artifacts expire after a few days. Solution: - Publish artifacts from `feature/x` branches to a fixed `pre-x` tag. - Publish artifacts from `master` branch to a fixed `prerelease` tag.
1 parent aff2a7a commit 69f3058

File tree

2 files changed

+113
-0
lines changed

2 files changed

+113
-0
lines changed

.github/workflows/release.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# This job performs the following:
2+
# - Publish prerelease (not release) artifacts for feature/x branches and "nightly" mainline.
3+
4+
name: Prerelease
5+
on:
6+
# schedule:
7+
# - cron: '5 5 * * *'
8+
workflow_dispatch:
9+
inputs:
10+
tag_name:
11+
description: 'Tag name for release'
12+
required: false
13+
default: prerelease
14+
push:
15+
branches: [master, feature/*]
16+
# tags:
17+
# - v[0-9]+.[0-9]+.[0-9]+
18+
19+
jobs:
20+
package:
21+
runs-on: ubuntu-latest
22+
env:
23+
NODE_OPTIONS: '--max-old-space-size=8192'
24+
outputs:
25+
feature: ${{ steps.build.outputs.feature }}
26+
tagname: ${{ steps.build.outputs.tagname }}
27+
version: ${{ steps.build.outputs.version }}
28+
changes: ${{ steps.build.outputs.changes }}
29+
steps:
30+
- uses: actions/checkout@v3
31+
with:
32+
fetch-depth: 0
33+
- name: Use Node.js ${{ matrix.node-version }}
34+
uses: actions/setup-node@v3
35+
with:
36+
node-version: ${{ matrix.node-version }}
37+
# - if: github.event_name == 'schedule'
38+
# run: echo 'TAG_NAME=prerelease' >> $GITHUB_ENV
39+
- if: github.event_name == 'workflow_dispatch'
40+
run: echo "TAG_NAME=${{ github.event.inputs.tag_name }}" >> $GITHUB_ENV
41+
- if: github.ref_name != 'master'
42+
run: |
43+
TAG_NAME=${{ github.ref_name }}
44+
FEAT_NAME=$(echo $TAG_NAME | sed 's/feature\///')
45+
echo "FEAT_NAME=$FEAT_NAME" >> $GITHUB_ENV
46+
echo "TAG_NAME=pre-$FEAT_NAME" >> $GITHUB_ENV
47+
- if: github.ref_name == 'master'
48+
run: |
49+
echo "FEAT_NAME=" >> $GITHUB_ENV
50+
echo "TAG_NAME=prerelease" >> $GITHUB_ENV
51+
- run: npm ci
52+
- name: vsix
53+
run: |
54+
npm run createRelease # Generate CHANGELOG.md
55+
npm run generateNonCodeFiles
56+
cp ./README.quickstart.vscode.md ./README.md
57+
npm run package -- --feature "$FEAT_NAME"
58+
- uses: actions/upload-artifact@v3
59+
with:
60+
name: artifacts
61+
path: '*.vsix'
62+
retention-days: 10
63+
- name: Export outputs
64+
id: build
65+
run: |
66+
echo "feature=$FEAT_NAME" >> $GITHUB_OUTPUT
67+
echo "tagname=$TAG_NAME" >> $GITHUB_OUTPUT
68+
echo "version=$(grep -m 1 version package.json | grep -o '[0-9][^\"]\+' | sed 's/-SNAPSHOT//')" >> $GITHUB_OUTPUT
69+
echo 'changes<<EOF' >> $GITHUB_OUTPUT
70+
head -14 CHANGELOG.md >> $GITHUB_OUTPUT
71+
echo 'EOF' >> $GITHUB_OUTPUT
72+
73+
publish:
74+
needs: [package]
75+
runs-on: ubuntu-latest
76+
env:
77+
# For `gh`.
78+
GH_REPO: ${{ github.repository }}
79+
# For `gh`.
80+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81+
FEAT_NAME: ${{ needs.package.outputs.feature }}
82+
TAG_NAME: ${{ needs.package.outputs.tagname }}
83+
AWS_TOOLKIT_VERSION: ${{ needs.package.outputs.version }}
84+
AWS_TOOLKIT_CHANGES: ${{ needs.package.outputs.changes }}
85+
permissions:
86+
contents: write
87+
steps:
88+
# Must perform checkout first, it deletes the target directory
89+
# before running, thus would delete the downloaded artifacts.
90+
- uses: actions/checkout@v3
91+
- uses: actions/download-artifact@v3
92+
- name: Delete existing prerelease
93+
# "prerelease" (main branch) or "pre-<feature>"
94+
if: "env.TAG_NAME == 'prerelease' || startsWith(env.TAG_NAME, 'pre-')"
95+
run: |
96+
echo "SUBJECT=AWS Toolkit ${AWS_TOOLKIT_VERSION}: ${FEAT_NAME:-${TAG_NAME}}" >> $GITHUB_ENV
97+
gh release delete "$TAG_NAME" --cleanup-tag --yes || true
98+
# git push origin :"$TAG_NAME" || true
99+
- name: Publish Prerelease
100+
run: |
101+
# AWS_TOOLKIT_CHANGES="$(head -14 CHANGELOG.md)"
102+
envsubst < "$GITHUB_WORKSPACE/.github/workflows/release_notes.md" > "$RUNNER_TEMP/release_notes.md"
103+
gh release create $TAG_NAME --prerelease --notes-file "$RUNNER_TEMP/release_notes.md" --title "$SUBJECT" --target $GITHUB_SHA artifacts/*

.github/workflows/release_notes.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
_This is an **unsupported preview build** of AWS Toolkit, for testing new features._
2+
3+
# Install
4+
5+
1. Download the vsix file from "Assets" below.
6+
2. In VSCode, run `Extensions: Install from VSIX...` and choose the vsix file.
7+
8+
# Changes
9+
10+
${AWS_TOOLKIT_CHANGES}

0 commit comments

Comments
 (0)