Skip to content

Commit 3670094

Browse files
authored
Merge #3548 ci: publish prerelease
2 parents ed260da + 69f3058 commit 3670094

File tree

3 files changed

+140
-11
lines changed

3 files changed

+140
-11
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}

scripts/build/package.ts

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,37 @@ function parseArgs() {
3434
// 1: /…/src/scripts/build/package.ts
3535
// 2: foo
3636

37+
const args: { [key: string]: any } = {
38+
/** Produce an unoptimized VSIX. Include git SHA in version string. */
39+
debug: false,
40+
/** Skips `npm run clean` when building the VSIX. This prevents file watching from breaking. */
41+
skipClean: false,
42+
feature: '',
43+
}
44+
3745
const givenArgs = process.argv.slice(2)
38-
const validOptions = ['--debug', '--no-clean']
46+
const validOptions = ['--debug', '--no-clean', '--feature']
47+
const expectValue = ['--feature']
3948

40-
for (const a of givenArgs) {
49+
for (let i = 0; i < givenArgs.length; i++) {
50+
const a = givenArgs[i]
51+
const argName = a.replace(/^-+/, '') // "--foo" => "foo"
4152
if (!validOptions.includes(a)) {
4253
throw Error(`invalid argument: ${a}`)
4354
}
55+
if (expectValue.includes(a)) {
56+
i++
57+
const val = givenArgs[i]
58+
if (val === undefined) {
59+
throw Error(`missing value for arg: ${a}`)
60+
}
61+
args[argName] = val
62+
} else {
63+
args[argName] = true
64+
}
4465
}
4566

46-
return {
47-
/** Produce an unoptimized VSIX. Include git SHA in version string. */
48-
debug: givenArgs.includes('--debug'),
49-
/** Skips `npm run clean` when building the VSIX. This prevents file watching from breaking. */
50-
skipClean: givenArgs.includes('--no-clean'),
51-
}
67+
return args
5268
}
5369

5470
/**
@@ -73,15 +89,15 @@ function isBeta(): boolean {
7389
*
7490
* @returns version-string suffix, for example: "-e6ecd84685a9"
7591
*/
76-
function getVersionSuffix(): string {
92+
function getVersionSuffix(feature: string): string {
7793
if (isRelease()) {
7894
return ''
7995
}
8096
const commitId = child_process.execSync('git rev-parse --short=12 HEAD').toString().trim()
8197
if (!commitId) {
8298
return ''
8399
}
84-
return `-${commitId}`
100+
return `${feature === '' ? '' : `-${feature}`}-${commitId}`
85101
}
86102

87103
function main() {
@@ -101,7 +117,7 @@ function main() {
101117
fs.copyFileSync(webpackConfigJsFile, `${webpackConfigJsFile}.bk`)
102118

103119
const packageJson: typeof manifest = JSON.parse(fs.readFileSync(packageJsonFile, { encoding: 'utf-8' }))
104-
const versionSuffix = getVersionSuffix()
120+
const versionSuffix = getVersionSuffix(args.feature)
105121
const version = packageJson.version
106122
// Setting the version to an arbitrarily high number stops VSC from auto-updating the beta extension
107123
const betaOrDebugVersion = `1.999.0${versionSuffix}`

0 commit comments

Comments
 (0)