Update release.yml #131
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
workflow_dispatch: | |
inputs: | |
generateDocOnly: | |
description: "Generate documentation only. Unchecking this checkbox will have no impact, the documentation will still be only generated when the workflow is triggered manually." | |
type: boolean | |
required: false | |
default: true | |
push: | |
branches: | |
- "release/v*" | |
jobs: | |
release: | |
name: Create Release | |
# We don't want to do a release if the workflow was dispatched manually | |
if: github.event_name != 'workflow_dispatch' | |
runs-on: ubuntu-latest | |
outputs: | |
release-asset-url: ${{ steps.create_release.outputs.upload_url }} | |
numeric-release-short: ${{ steps.format.outputs.numeric_release_short }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
persist-credentials: true | |
- name: Format Branch Name | |
id: format | |
env: | |
GITHUB_REF: ${{ github.ref }} | |
run: | | |
git fetch --tags | |
echo ::set-output name=branch_name::$(echo "${GITHUB_REF}" | cut -d/ -f3-) | |
echo ::set-output name=tag_name::$(echo "${GITHUB_REF}" | cut -d/ -f4-) | |
echo ::set-output name=numeric_release::$(echo "${GITHUB_REF}" | cut -d/ -f4- | tr -d v) | |
echo ::set-output name=numeric_release_short::$(echo "${GITHUB_REF}" | cut -d/ -f4- | tr -d v.-) | |
echo ::set-output name=release_name::"Release $(echo "${GITHUB_REF}" | cut -d/ -f4-)" | |
- name: Use Node.js | |
uses: actions/setup-node@v1 | |
env: | |
RUNNER_TEMP: /tmp/runner | |
with: | |
node-version: 18 | |
- name: Install pnpm | |
run: | | |
npm install -g [email protected] | |
- name: Generate Changelog | |
id: changelog | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GITHUB_DEFAULT_BRANCH: ${{ steps.format.outputs.branch_name }} | |
run: | | |
previous_tag=$(git describe --tags --abbrev=0) | |
echo "Previous release was: ${previous_tag}" | |
changes=$(git log ${previous_tag}..HEAD --pretty="tformat:* %s (%h)" --first-parent) | |
echo ${changes} | |
changes="${changes//'%'/'%25'}" # Avoids whitespace removal. | |
changes="${changes//$'\n'/'%0A'}" | |
changes="${changes//$'\r'/'%0D'}" | |
echo ::set-output name=changelog::${changes} | |
- name: Bump package.json | |
run: | | |
npm install -g json | |
git config user.name github-actions | |
git config user.email [email protected] | |
json -I -f src/core/cdk/package.json -e 'this.version="${{ steps.format.outputs.numeric_release }}"' | |
git add src/core/cdk/package.json | |
json -I -f src/installer/cdk/package.json -e 'this.version="${{ steps.format.outputs.numeric_release }}"' | |
git add src/installer/cdk/package.json | |
git commit -am 'Updating package to ${{ steps.format.outputs.numeric_release }}' | |
- name: Push Bumped Package Files | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ steps.format.outputs.branch_name }} | |
- name: Build Accelerator Installer | |
id: build | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GITHUB_DEFAULT_BRANCH: ${{ steps.format.outputs.branch_name }} | |
INSTALLER_STACK_DIR: ./src/installer/cdk | |
INSTALLER_STACK_NAME: AcceleratorInstaller | |
NUMERIC_RELEASE_SHORT: ${{ steps.format.outputs.numeric_release_short }} | |
OUTPUT_DIR: templates | |
run: | | |
cd "${INSTALLER_STACK_DIR}" | |
pnpm install --frozen-lockfile | |
pnpx cdk synth --output "${OUTPUT_DIR}" "${INSTALLER_STACK_NAME}" | |
echo ::set-output name=template_name::${INSTALLER_STACK_NAME}-GitHub.template.json | |
echo ::set-output name=template_name_code_commit::${INSTALLER_STACK_NAME}-CodeCommit.template.json | |
echo ::set-output name=template_name_with_version::${INSTALLER_STACK_NAME}${NUMERIC_RELEASE_SHORT}-GitHub.template.json | |
echo ::set-output name=template_name_with_version_code_commit::${INSTALLER_STACK_NAME}${NUMERIC_RELEASE_SHORT}-CodeCommit.template.json | |
echo ::set-output name=template_path::$(realpath "${OUTPUT_DIR}/${INSTALLER_STACK_NAME}.template.json") | |
echo ::set-output name=template_path_code_commit::$(realpath "${OUTPUT_DIR}/${INSTALLER_STACK_NAME}-CodeCommit.template.json") | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@latest | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.format.outputs.tag_name }} | |
release_name: ${{ steps.format.outputs.release_name }} | |
body: | | |
${{ steps.changelog.outputs.changelog }} | |
draft: true | |
prerelease: false | |
- name: Upload Artifact - AcceleratorInstaller-GitHub | |
uses: actions/upload-artifact@v4 | |
with: | |
path: ${{ steps.build.outputs.template_path }} | |
name: ${{ steps.build.outputs.template_name }} | |
- name: Upload Artifact - AcceleratorInstaller-CodeCommit | |
uses: actions/upload-artifact@v4 | |
with: | |
path: ${{ steps.build.outputs.template_path_code_commit }} | |
name: ${{ steps.build.outputs.template_name_code_commit }} | |
- name: Upload Release Asset - AcceleratorInstaller-GitHub | |
id: upload-release-asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ${{ steps.build.outputs.template_path }} | |
asset_name: ${{ steps.build.outputs.template_name_with_version }} | |
asset_content_type: application/json | |
- name: Upload Release Asset - AcceleratorInstaller-CodeCommit | |
id: upload-release-asset-code-commmit | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ${{ steps.build.outputs.template_path_code_commit }} | |
asset_name: ${{ steps.build.outputs.template_name_with_version_code_commit }} | |
asset_content_type: application/json | |
- name: Get Draft Release Url | |
id: release_url | |
run: | | |
echo "Draft release available at: ${{ steps.create_release.outputs.html_url}}" | |
build-sea-config-schema: | |
name: Build SEA-Config-Schema | |
runs-on: ubuntu-latest | |
outputs: | |
release-asset-name: ${{ steps.build.outputs.release-asset-name }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
persist-credentials: true | |
- name: Use Node.js | |
uses: actions/setup-node@v1 | |
env: | |
RUNNER_TEMP: /tmp/runner | |
with: | |
node-version: 18 | |
- name: Install pnpm | |
run: | | |
npm install -g [email protected] | |
- name: Build SEA-Config-Schema project | |
id: build | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
BUILD_DIR: ./src/lib/docs-gen | |
OUTPUT_DIR: output-docs | |
BUILD_ASSET_NAME: AWS-SEA-Config-Schema-DRAFT.zip | |
run: | | |
pnpm install --frozen-lockfile | |
cd "${BUILD_DIR}" | |
pnpm build | |
echo ::set-output name=release-path::$(realpath "./${OUTPUT_DIR}") | |
echo ::set-output name=release-asset-name::${BUILD_ASSET_NAME} | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.build.outputs.release-asset-name }} | |
path: ${{ steps.build.outputs.release-path }} | |
build-sea-gui: | |
name: Build SEA-GUI | |
runs-on: ubuntu-latest | |
outputs: | |
release-asset-name: ${{ steps.build.outputs.release-asset-name }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
persist-credentials: true | |
- name: Use Node.js | |
uses: actions/setup-node@v1 | |
env: | |
RUNNER_TEMP: /tmp/runner | |
with: | |
node-version: 18 | |
- name: Install pnpm | |
run: | | |
npm install -g [email protected] | |
- name: Build SEA-GUI project | |
id: build | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
BUILD_DIR: ./src/ui | |
OUTPUT_DIR: build | |
BUILD_ASSET_NAME: AWS-SEA-GUI-mockup-DoNotUse-alpha.zip | |
run: | | |
pnpm install --frozen-lockfile | |
cd "${BUILD_DIR}" | |
pnpm build:ui | |
echo ::set-output name=release-path::$(realpath "./${OUTPUT_DIR}") | |
echo ::set-output name=release-asset-name::${BUILD_ASSET_NAME} | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.build.outputs.release-asset-name }} | |
path: ${{ steps.build.outputs.release-path }} | |
upload-archive-to-release: | |
# We don't want to upload artifact to the release if the workflow was dispatched manually | |
if: github.event_name != 'workflow_dispatch' | |
needs: [release, build-sea-gui, build-sea-config-schema] | |
name: Upload Archives to Release | |
runs-on: ubuntu-latest | |
steps: | |
- name: SEA-GUI - Download Archive | |
uses: actions/download-artifact@v4 | |
id: download-archive-sea-gui | |
with: | |
name: ${{ needs.build-sea-gui.outputs.release-asset-name }} | |
path: download-archive-sea-gui | |
- name: SEA-GUI - Create Archive | |
id: create-archive-sea-gui | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NUMERIC_RELEASE_SHORT: ${{ needs.release.outputs.numeric-release-short }} | |
OUTPUT_DIR: ${{ steps.download-archive-sea-gui.outputs.download-path }} | |
run: | | |
cd "${OUTPUT_DIR}" | |
zip -r archive.zip * | |
echo ::set-output name=release-path::$(realpath "./archive.zip") | |
echo ::set-output name=release-asset-name::AWS-SEA-GUI-mockup-DoNotUse-v${NUMERIC_RELEASE_SHORT}-alpha.zip | |
- name: SEA-GUI - Upload Release Asset | |
id: upload-release-asset-sea-gui | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.release.outputs.release-asset-url }} | |
asset_path: ${{ steps.create-archive-sea-gui.outputs.release-path }} | |
asset_name: ${{ steps.create-archive-sea-gui.outputs.release-asset-name }} | |
asset_content_type: application/zip | |
- name: SEA-Config-Schema - Download Archive | |
uses: actions/download-artifact@v4 | |
id: download-archive-sea-config-schema | |
with: | |
name: ${{ needs.build-sea-config-schema.outputs.release-asset-name }} | |
path: download-archive-sea-config-schema | |
- name: SEA-Config-Schema - Create Archive | |
id: create-archive-sea-config-schema | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NUMERIC_RELEASE_SHORT: ${{ needs.release.outputs.numeric-release-short }} | |
OUTPUT_DIR: ${{ steps.download-archive-sea-config-schema.outputs.download-path }} | |
run: | | |
cd "${OUTPUT_DIR}" | |
zip -r archive.zip * | |
echo ::set-output name=release-path::$(realpath "./archive.zip") | |
echo ::set-output name=release-asset-name::AWS-SEA-Config-Schema-v${NUMERIC_RELEASE_SHORT}-DRAFT.zip | |
- name: SEA-Config-Schema - Upload Release Asset | |
id: upload-release-asset-sea-config-schema | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.release.outputs.release-asset-url }} | |
asset_path: ${{ steps.create-archive-sea-config-schema.outputs.release-path }} | |
asset_name: ${{ steps.create-archive-sea-config-schema.outputs.release-asset-name }} | |
asset_content_type: application/zip |