forked from aws/aws-toolkit-vscode
-
Notifications
You must be signed in to change notification settings - Fork 0
118 lines (115 loc) · 5.42 KB
/
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
# This job performs the following:
# - Publish prerelease (not release) artifacts for feature/x branches and "nightly" mainline.
name: Prerelease
on:
# schedule:
# - cron: '5 5 * * *'
workflow_dispatch:
inputs:
tag_name:
description: 'Tag name for release'
required: false
default: prerelease
push:
branches: [master, feature/*]
# tags:
# - v[0-9]+.[0-9]+.[0-9]+
jobs:
package:
runs-on: ubuntu-latest
env:
NODE_OPTIONS: '--max-old-space-size=8192'
outputs:
feature: ${{ steps.build.outputs.feature }}
tagname: ${{ steps.build.outputs.tagname }}
toolkit_version: ${{ steps.build.outputs.toolkit_version }}
amazonq_version: ${{ steps.build.outputs.amazonq_version }}
toolkit_changes: ${{ steps.build.outputs.toolkit_changes }}
amazonq_changes: ${{ steps.build.outputs.amazonq_changes }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
# - if: github.event_name == 'schedule'
# run: echo 'TAG_NAME=prerelease' >> $GITHUB_ENV
- if: github.event_name == 'workflow_dispatch'
run: echo "TAG_NAME=${{ github.event.inputs.tag_name }}" >> $GITHUB_ENV
- if: github.ref_name != 'master'
run: |
TAG_NAME=${{ github.ref_name }}
FEAT_NAME=$(echo $TAG_NAME | sed 's/feature\///')
echo "FEAT_NAME=$FEAT_NAME" >> $GITHUB_ENV
echo "TAG_NAME=pre-$FEAT_NAME" >> $GITHUB_ENV
- if: github.ref_name == 'master'
run: |
echo "FEAT_NAME=" >> $GITHUB_ENV
echo "TAG_NAME=prerelease" >> $GITHUB_ENV
- run: npm ci
- name: vsix
run: |
npm run createRelease -w packages/toolkit -w packages/amazonq # Generate CHANGELOG.md
npm run -w packages/toolkit package -- --feature "$FEAT_NAME"
npm run -w packages/amazonq package -- --feature "$FEAT_NAME"
- uses: actions/upload-artifact@v4
with:
name: artifacts
path: '*.vsix'
retention-days: 10
- name: Export outputs
id: build
run: |
write_package_info() {
PKG_NAME=$1
PKG_DISPLAY_NAME=$(grep -m 1 displayName packages/${PKG_NAME}/package.json | grep -o '[a-zA-z][^\"]\+' | tail -n1)
echo "${PKG_NAME}_version=$(grep -m 1 version packages/${PKG_NAME}/package.json | grep -o '[0-9][^\"]\+' | sed 's/-SNAPSHOT//')" >> $GITHUB_OUTPUT
echo "${PKG_NAME}_changes<<EOF" >> $GITHUB_OUTPUT
# Add extension display name to the topmost changelog section.
cat packages/${PKG_NAME}/CHANGELOG.md | perl -ne 'BEGIN{$/="\n\n"} print; exit if $. == 2' | sed -e "1 s/## /## ${PKG_DISPLAY_NAME} - /" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
}
echo "feature=$FEAT_NAME" >> $GITHUB_OUTPUT
echo "tagname=$TAG_NAME" >> $GITHUB_OUTPUT
write_package_info toolkit
write_package_info amazonq
publish:
needs: [package]
runs-on: ubuntu-latest
env:
#
# For `gh`.
#
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FEAT_NAME: ${{ needs.package.outputs.feature }}
TAG_NAME: ${{ needs.package.outputs.tagname }}
AWS_TOOLKIT_VERSION: ${{ needs.package.outputs.toolkit_version }}
AMAZON_Q_VERSION: ${{ needs.package.outputs.amazonq_version }}
#
# Used in release_notes.md
#
BRANCH: ${{ github.ref_name }}
AWS_TOOLKIT_CHANGES: ${{ needs.package.outputs.toolkit_changes }}
AMAZON_Q_CHANGES: ${{ needs.package.outputs.amazonq_changes }}
permissions:
contents: write
steps:
# Must perform checkout first, it deletes the target directory
# before running, thus would delete the downloaded artifacts.
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
- name: Delete existing prerelease
# "prerelease" (main branch) or "pre-<feature>"
if: "env.TAG_NAME == 'prerelease' || startsWith(env.TAG_NAME, 'pre-')"
run: |
echo "SUBJECT=AWS IDE Extensions: ${FEAT_NAME:-${TAG_NAME}}" >> $GITHUB_ENV
gh release delete "$TAG_NAME" --cleanup-tag --yes || true
# git push origin :"$TAG_NAME" || true
- name: Publish Prerelease
run: |
# AWS_TOOLKIT_CHANGES="$(head -14 CHANGELOG.md)"
envsubst < "$GITHUB_WORKSPACE/.github/workflows/release_notes.md" > "$RUNNER_TEMP/release_notes.md"
gh release create $TAG_NAME --prerelease --notes-file "$RUNNER_TEMP/release_notes.md" --title "$SUBJECT" --target $GITHUB_SHA artifacts/*