Skip to content

Commit 6694753

Browse files
authored
Hack together on-push builds for feature/q-mega (#5074)
Per product request. Tested in internal branch
1 parent 2c5ea56 commit 6694753

File tree

2 files changed

+173
-2
lines changed

2 files changed

+173
-2
lines changed

.github/workflows/generateUpdatesXml.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
xml = ['<?xml version="1.0" encoding="UTF-8"?>', '<plugins>']
1414

1515
buildRegex = r'.*(\d{3}).zip'
16+
# given plugin-amazonq-3.39-SNAPSHOT-1731096007-241.zip,
17+
# capture 3.39-SNAPSHOT-1731096007-241 in group 1
18+
versionRegex = r'.*?\-(\d.*-\d{3})\.zip'
1619
for asset in data['assets']:
1720
name = asset['name']
1821
if ('plugin-amazonq' in name):
@@ -21,9 +24,13 @@
2124
plugin = 'aws.toolkit.core'
2225
else:
2326
plugin = 'aws.toolkit'
24-
build = re.match(buildRegex, name).group(1)
27+
build = re.match(buildRegex, name)
28+
if build == None:
29+
continue
30+
build = build.group(1)
31+
version = re.match(versionRegex, name).group(1)
2532

26-
xml.append(f'''<plugin id="{plugin}" url="{asset['url']}" version="999">
33+
xml.append(f'''<plugin id="{plugin}" url="{asset['url']}" version="{version}">
2734
<idea-version since-build="{build}" until-build="{build}.*"/>
2835
</plugin>''')
2936

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
name: Prerelease Q-only
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
tag_name:
6+
description: 'Tag name for release'
7+
required: false
8+
default: prerelease
9+
push:
10+
branches: [ feature/q-mega ]
11+
12+
jobs:
13+
time:
14+
outputs:
15+
time: ${{ steps.time.outputs.time }}
16+
runs-on: ubuntu-latest
17+
steps:
18+
- id: time
19+
run: |
20+
echo "time=$(date +%s)" >> "$GITHUB_OUTPUT"
21+
22+
generate_artifact_q:
23+
needs: [ time ]
24+
strategy:
25+
matrix:
26+
supported_versions: [ '2023.3', '2024.1', '2024.2', '2024.3' ]
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0
32+
- name: remove unwanted dependencies
33+
run: |
34+
sudo rm -rf /usr/share/dotnet
35+
sudo rm -rf /opt/ghc
36+
sudo rm -rf "/usr/local/share/boost"
37+
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
38+
- uses: actions/setup-java@v4
39+
with:
40+
distribution: 'corretto'
41+
java-version: '21'
42+
- name: Generate artifact
43+
run: |
44+
sed -i.bak "s/\(toolkitVersion\s*=\s*\)\(.*\)/\1\2-${{ needs.time.outputs.time }}/" gradle.properties
45+
./gradlew -PideProfileName=${{ matrix.supported_versions }} :plugin-amazonq:buildPlugin
46+
- name: Upload artifact
47+
uses: actions/upload-artifact@v4
48+
with:
49+
name: plugin-amazonq-${{ matrix.supported_versions }}
50+
path: ./plugins/amazonq/build/distributions/*.zip
51+
retention-days: 1
52+
53+
generate_artifact_core:
54+
needs: [ time ]
55+
strategy:
56+
matrix:
57+
supported_versions: [ '2023.3', '2024.1', '2024.2', '2024.3' ]
58+
runs-on: ubuntu-latest
59+
steps:
60+
- uses: actions/checkout@v4
61+
with:
62+
fetch-depth: 0
63+
- name: remove unwanted dependencies
64+
run: |
65+
sudo rm -rf /usr/share/dotnet
66+
sudo rm -rf /opt/ghc
67+
sudo rm -rf "/usr/local/share/boost"
68+
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
69+
- uses: actions/setup-java@v4
70+
with:
71+
distribution: 'corretto'
72+
java-version: '21'
73+
74+
- name: Generate artifact
75+
run: |
76+
sed -i.bak "s/\(toolkitVersion\s*=\s*\)\(.*\)/\1\2-${{ needs.time.outputs.time }}/" gradle.properties
77+
./gradlew -PideProfileName=${{ matrix.supported_versions }} :plugin-core:buildPlugin
78+
- name: Upload artifact
79+
uses: actions/upload-artifact@v4
80+
with:
81+
name: plugin-core-${{ matrix.supported_versions }}
82+
path: ./plugins/core/build/distributions/*.zip
83+
retention-days: 1
84+
85+
generate_changelog:
86+
needs: [ time ]
87+
runs-on: ubuntu-latest
88+
outputs:
89+
feature: ${{ steps.assign_output.outputs.feature }}
90+
tagname: ${{ steps.assign_output.outputs.tagname }}
91+
version: ${{ steps.assign_output.outputs.version }}
92+
changes: ${{ steps.assign_output.outputs.changes }}
93+
steps:
94+
- uses: actions/checkout@v4
95+
96+
- uses: actions/setup-java@v4
97+
with:
98+
distribution: 'corretto'
99+
java-version: '21'
100+
101+
- if: github.event_name == 'workflow_dispatch'
102+
run: |
103+
echo "TAG_NAME=${{ github.event.inputs.tag_name }}" >> $GITHUB_ENV
104+
- if: github.ref_name != 'main'
105+
run: |
106+
TAG_NAME=${{ github.ref_name }}
107+
FEAT_NAME=$(echo $TAG_NAME | sed 's/feature\///')
108+
echo "FEAT_NAME=$FEAT_NAME" >> $GITHUB_ENV
109+
echo "TAG_NAME=pre-$FEAT_NAME" >> $GITHUB_ENV
110+
- if: github.ref_name == 'main'
111+
run: |
112+
echo "FEAT_NAME=" >> $GITHUB_ENV
113+
echo "TAG_NAME=prerelease" >> $GITHUB_ENV
114+
- name: Generate changelog
115+
id: changelog
116+
run: |
117+
sed -i.bak "s/\(toolkitVersion\s*=\s*\)\(.*\)/\1\2-${{ needs.time.outputs.time }}/" gradle.properties
118+
./gradlew :createRelease :generateChangelog
119+
- name: Provide the metadata to output
120+
id: assign_output
121+
run: |
122+
echo "feature=$FEAT_NAME" >> $GITHUB_OUTPUT
123+
echo "tagname=$TAG_NAME" >> $GITHUB_OUTPUT
124+
echo "version=$(cat gradle.properties | grep toolkitVersion | cut -d'=' -f2)" >> $GITHUB_OUTPUT
125+
echo 'changes<<EOF' >> $GITHUB_OUTPUT
126+
cat CHANGELOG.md | perl -ne 'BEGIN{$/="\n\n"} print; exit if $. == 1' >> $GITHUB_OUTPUT
127+
echo 'EOF' >> $GITHUB_OUTPUT
128+
129+
publish:
130+
needs: [ generate_artifact_core, generate_artifact_q, generate_changelog ]
131+
env:
132+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
133+
GH_REPO: ${{ github.repository }}
134+
FEAT_NAME: ${{ needs.generate_changelog.outputs.feature }}
135+
TAG_NAME: ${{ needs.generate_changelog.outputs.tagname }}
136+
AWS_TOOLKIT_VERSION: ${{ needs.generate_changelog.outputs.version }}
137+
BRANCH: ${{ github.ref_name }}
138+
AWS_TOOLKIT_CHANGES: ${{ needs.generate_changelog.outputs.changes }}
139+
runs-on: ubuntu-latest
140+
permissions:
141+
contents: write
142+
steps:
143+
- uses: actions/checkout@v4
144+
- uses: actions/download-artifact@v4
145+
- name: Delete existing prerelease
146+
# "prerelease" (main branch) or "pre-<feature>"
147+
if: "env.TAG_NAME == 'prerelease' || startsWith(env.TAG_NAME, 'pre-')"
148+
run: |
149+
echo "SUBJECT=AWS Toolkit ${AWS_TOOLKIT_VERSION}: ${FEAT_NAME:-${TAG_NAME}}" >> $GITHUB_ENV
150+
gh release delete "$TAG_NAME" --cleanup-tag --yes || true
151+
- name: Publish to GitHub Releases
152+
run: |
153+
envsubst < "$GITHUB_WORKSPACE/.github/workflows/prerelease_notes.md" > "$RUNNER_TEMP/prerelease_notes.md"
154+
gh release create "$TAG_NAME" --prerelease --notes-file "$RUNNER_TEMP/prerelease_notes.md" --title "$SUBJECT" --target $GITHUB_SHA
155+
- name: Publish core
156+
run: |
157+
gh release upload "$TAG_NAME" plugin-core-*/*.zip
158+
- name: Publish Q
159+
run: |
160+
gh release upload "$TAG_NAME" plugin-amazonq-*/*.zip
161+
- name: Publish XML manifest
162+
run: |
163+
gh release view "$TAG_NAME" --repo "$GITHUB_REPOSITORY" --json assets | python3 "$GITHUB_WORKSPACE/.github/workflows/generateUpdatesXml.py" - > updatePlugins.xml
164+
gh release upload "$TAG_NAME" updatePlugins.xml

0 commit comments

Comments
 (0)