diff --git a/.github/workflows/generateUpdatesXml.py b/.github/workflows/generateUpdatesXml.py index b73b56315c3..2153a4a0e33 100644 --- a/.github/workflows/generateUpdatesXml.py +++ b/.github/workflows/generateUpdatesXml.py @@ -13,6 +13,9 @@ xml = ['', ''] buildRegex = r'.*(\d{3}).zip' + # given plugin-amazonq-3.39-SNAPSHOT-1731096007-241.zip, + # capture 3.39-SNAPSHOT-1731096007-241 in group 1 + versionRegex = r'.*?\-(\d.*-\d{3})\.zip' for asset in data['assets']: name = asset['name'] if ('plugin-amazonq' in name): @@ -21,9 +24,13 @@ plugin = 'aws.toolkit.core' else: plugin = 'aws.toolkit' - build = re.match(buildRegex, name).group(1) + build = re.match(buildRegex, name) + if build == None: + continue + build = build.group(1) + version = re.match(versionRegex, name).group(1) - xml.append(f''' + xml.append(f''' ''') diff --git a/.github/workflows/q-mega-prerelease.yml b/.github/workflows/q-mega-prerelease.yml new file mode 100644 index 00000000000..1f783a5b886 --- /dev/null +++ b/.github/workflows/q-mega-prerelease.yml @@ -0,0 +1,164 @@ +name: Prerelease Q-only +on: + workflow_dispatch: + inputs: + tag_name: + description: 'Tag name for release' + required: false + default: prerelease + push: + branches: [ feature/q-mega ] + +jobs: + time: + outputs: + time: ${{ steps.time.outputs.time }} + runs-on: ubuntu-latest + steps: + - id: time + run: | + echo "time=$(date +%s)" >> "$GITHUB_OUTPUT" + + generate_artifact_q: + needs: [ time ] + strategy: + matrix: + supported_versions: [ '2023.3', '2024.1', '2024.2', '2024.3' ] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: remove unwanted dependencies + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf /opt/ghc + sudo rm -rf "/usr/local/share/boost" + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + - uses: actions/setup-java@v4 + with: + distribution: 'corretto' + java-version: '21' + - name: Generate artifact + run: | + sed -i.bak "s/\(toolkitVersion\s*=\s*\)\(.*\)/\1\2-${{ needs.time.outputs.time }}/" gradle.properties + ./gradlew -PideProfileName=${{ matrix.supported_versions }} :plugin-amazonq:buildPlugin + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: plugin-amazonq-${{ matrix.supported_versions }} + path: ./plugins/amazonq/build/distributions/*.zip + retention-days: 1 + + generate_artifact_core: + needs: [ time ] + strategy: + matrix: + supported_versions: [ '2023.3', '2024.1', '2024.2', '2024.3' ] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: remove unwanted dependencies + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf /opt/ghc + sudo rm -rf "/usr/local/share/boost" + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + - uses: actions/setup-java@v4 + with: + distribution: 'corretto' + java-version: '21' + + - name: Generate artifact + run: | + sed -i.bak "s/\(toolkitVersion\s*=\s*\)\(.*\)/\1\2-${{ needs.time.outputs.time }}/" gradle.properties + ./gradlew -PideProfileName=${{ matrix.supported_versions }} :plugin-core:buildPlugin + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: plugin-core-${{ matrix.supported_versions }} + path: ./plugins/core/build/distributions/*.zip + retention-days: 1 + + generate_changelog: + needs: [ time ] + runs-on: ubuntu-latest + outputs: + feature: ${{ steps.assign_output.outputs.feature }} + tagname: ${{ steps.assign_output.outputs.tagname }} + version: ${{ steps.assign_output.outputs.version }} + changes: ${{ steps.assign_output.outputs.changes }} + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-java@v4 + with: + distribution: 'corretto' + java-version: '21' + + - if: github.event_name == 'workflow_dispatch' + run: | + echo "TAG_NAME=${{ github.event.inputs.tag_name }}" >> $GITHUB_ENV + - if: github.ref_name != 'main' + 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 == 'main' + run: | + echo "FEAT_NAME=" >> $GITHUB_ENV + echo "TAG_NAME=prerelease" >> $GITHUB_ENV + - name: Generate changelog + id: changelog + run: | + sed -i.bak "s/\(toolkitVersion\s*=\s*\)\(.*\)/\1\2-${{ needs.time.outputs.time }}/" gradle.properties + ./gradlew :createRelease :generateChangelog + - name: Provide the metadata to output + id: assign_output + run: | + echo "feature=$FEAT_NAME" >> $GITHUB_OUTPUT + echo "tagname=$TAG_NAME" >> $GITHUB_OUTPUT + echo "version=$(cat gradle.properties | grep toolkitVersion | cut -d'=' -f2)" >> $GITHUB_OUTPUT + echo 'changes<> $GITHUB_OUTPUT + cat CHANGELOG.md | perl -ne 'BEGIN{$/="\n\n"} print; exit if $. == 1' >> $GITHUB_OUTPUT + echo 'EOF' >> $GITHUB_OUTPUT + + publish: + needs: [ generate_artifact_core, generate_artifact_q, generate_changelog ] + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + FEAT_NAME: ${{ needs.generate_changelog.outputs.feature }} + TAG_NAME: ${{ needs.generate_changelog.outputs.tagname }} + AWS_TOOLKIT_VERSION: ${{ needs.generate_changelog.outputs.version }} + BRANCH: ${{ github.ref_name }} + AWS_TOOLKIT_CHANGES: ${{ needs.generate_changelog.outputs.changes }} + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + - name: Delete existing prerelease + # "prerelease" (main branch) or "pre-" + if: "env.TAG_NAME == 'prerelease' || startsWith(env.TAG_NAME, 'pre-')" + run: | + echo "SUBJECT=AWS Toolkit ${AWS_TOOLKIT_VERSION}: ${FEAT_NAME:-${TAG_NAME}}" >> $GITHUB_ENV + gh release delete "$TAG_NAME" --cleanup-tag --yes || true + - name: Publish to GitHub Releases + run: | + envsubst < "$GITHUB_WORKSPACE/.github/workflows/prerelease_notes.md" > "$RUNNER_TEMP/prerelease_notes.md" + gh release create "$TAG_NAME" --prerelease --notes-file "$RUNNER_TEMP/prerelease_notes.md" --title "$SUBJECT" --target $GITHUB_SHA + - name: Publish core + run: | + gh release upload "$TAG_NAME" plugin-core-*/*.zip + - name: Publish Q + run: | + gh release upload "$TAG_NAME" plugin-amazonq-*/*.zip + - name: Publish XML manifest + run: | + gh release view "$TAG_NAME" --repo "$GITHUB_REPOSITORY" --json assets | python3 "$GITHUB_WORKSPACE/.github/workflows/generateUpdatesXml.py" - > updatePlugins.xml + gh release upload "$TAG_NAME" updatePlugins.xml