Skip to content

Commit

Permalink
chore: merge v2 branch
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenfonseca authored Oct 20, 2022
2 parents ac48766 + b4a12b2 commit 0bee23c
Show file tree
Hide file tree
Showing 130 changed files with 5,182 additions and 2,998 deletions.
35 changes: 32 additions & 3 deletions .github/workflows/on_release_notes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ env:

on:
release:
# We can't filter by tag here, so we filter later on the first job
types: [published]

workflow_dispatch:
inputs:
version_to_publish:
description: "Version to be released in PyPi, Docs, and Lambda Layer, e.g. v1.26.4"
default: v1.26.4
default: v2.0.0
required: true
skip_pypi:
description: "Skip publishing to PyPi as it can't publish more than once. Useful for semi-failed releases"
Expand All @@ -42,9 +44,15 @@ on:
default: false
type: boolean
required: false
pre_release:
description: "Publishes documentation using a pre-release tag. You are still responsible for passing a pre-release version tag to the workflow."
default: false
type: boolean
required: false

jobs:
release:
if: ${{ startsWith(github.ref, 'refs/tags/v2') }}
environment: release
runs-on: ubuntu-latest
permissions:
Expand Down Expand Up @@ -110,17 +118,38 @@ jobs:
contents: write
uses: ./.github/workflows/reusable_publish_changelog.yml

# When doing a pre-release, we want to publish the docs as "alpha" instead of replacing the latest docs
prepare_docs_alias:
runs-on: ubuntu-latest
outputs:
DOCS_ALIAS: ${{ steps.set-alias.outputs.DOCS_ALIAS }}
steps:
- name: Set docs alias
id: set-alias
run: |
DOCS_ALIAS=latest
if [[ "${{ github.event.release.prerelease || inputs.pre_release }}" == true ]] ; then
DOCS_ALIAS=alpha
fi
echo DOCS_ALIAS="$DOCS_ALIAS" >> "$GITHUB_OUTPUT"
docs:
needs: [release, changelog]
needs: [release, changelog, prepare_docs_alias]
permissions:
contents: write
pages: write
uses: ./.github/workflows/reusable_publish_docs.yml
with:
version: ${{ needs.release.outputs.RELEASE_VERSION }}
alias: latest
alias: ${{ needs.prepare_docs_alias.outputs.DOCS_ALIAS }}
detached_mode: true

publish_layer:
needs: release
uses: ./.github/workflows/publish_v2_layer.yml
with:
latest_published_version: ${{ needs.release.outputs.RELEASE_VERSION }}

post_release:
needs: release
permissions:
Expand Down
86 changes: 0 additions & 86 deletions .github/workflows/publish_layer.yml

This file was deleted.

104 changes: 100 additions & 4 deletions .github/workflows/publish_v2_layer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,108 @@ on:
workflow_dispatch:
inputs:
latest_published_version:
description: "Latest PyPi published version to rebuild latest docs for, e.g. v1.22.0"
description: "Latest PyPi published version to rebuild latest docs for, e.g. v2.0.0"
required: true
workflow_call:
inputs:
latest_published_version:
type: string
description: "Latest PyPi published version to rebuild latest docs for, e.g. v2.0.0"
required: true

jobs:
dummy:
build-layer:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./layer
outputs:
release-tag-version: ${{ steps.release-notes-tag.outputs.RELEASE_TAG_VERSION }}
steps:
- name: Hello world
run: echo "hello world"
- name: checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install poetry
run: pipx install poetry
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "16.12"
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: "3.9"
cache: "pip"
- name: Resolve and install project dependencies
# CDK spawns system python when compiling stack
# therefore it ignores both activated virtual env and cached interpreter by GH
run: |
poetry export --format requirements.txt --output requirements.txt
pip install -r requirements.txt
- name: Set release notes tag
id: release-notes-tag
run: |
RELEASE_INPUT=${{ inputs.latest_published_version }}
LATEST_TAG=$(git describe --tag --abbrev=0)
RELEASE_TAG_VERSION=${RELEASE_INPUT:-$LATEST_TAG}
echo RELEASE_TAG_VERSION="${RELEASE_TAG_VERSION:1}" >> "$GITHUB_OUTPUT"
- name: Set up QEMU
uses: docker/setup-qemu-action@8b122486cedac8393e77aa9734c3528886e4a1a8 # v2.0.0
# NOTE: we need QEMU to build Layer against a different architecture (e.g., ARM)
- name: Set up Docker Buildx
id: builder
uses: docker/setup-buildx-action@dc7b9719a96d48369863986a06765841d7ea23f6 # v2.0.0
- name: install cdk and deps
run: |
npm install -g [email protected]
cdk --version
- name: CDK build
run: cdk synth --context version="${{ steps.release-notes-tag.outputs.RELEASE_TAG_VERSION }}" -o cdk.out
- name: zip output
run: zip -r cdk.out.zip cdk.out
- name: Archive CDK artifacts
uses: actions/upload-artifact@v3
with:
name: cdk-layer-artefact
path: layer/cdk.out.zip

deploy-beta:
needs: build-layer
uses: ./.github/workflows/reusable_deploy_v2_layer_stack.yml
secrets: inherit
with:
stage: "BETA"
artefact-name: "cdk-layer-artefact"
environment: "layer-beta"
latest_published_version: ${{ inputs.latest_published_version }}

deploy-prod:
needs: deploy-beta
uses: ./.github/workflows/reusable_deploy_v2_layer_stack.yml
secrets: inherit
with:
stage: "PROD"
artefact-name: "cdk-layer-artefact"
environment: "layer-prod"
latest_published_version: ${{ inputs.latest_published_version }}

deploy-sar-beta:
needs: build-layer
uses: ./.github/workflows/reusable_deploy_v2_sar.yml
secrets: inherit
with:
stage: "BETA"
artefact-name: "cdk-layer-artefact"
environment: "layer-beta"
package-version: ${{ needs.build-layer.outputs.release-tag-version }}

deploy-sar-prod:
needs: [build-layer, deploy-sar-beta]
uses: ./.github/workflows/reusable_deploy_v2_sar.yml
secrets: inherit
with:
stage: "PROD"
artefact-name: "cdk-layer-artefact"
environment: "layer-prod"
package-version: ${{ needs.build-layer.outputs.release-tag-version }}
4 changes: 2 additions & 2 deletions .github/workflows/rebuild_latest_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ on:
workflow_dispatch:
inputs:
latest_published_version:
description: "Latest PyPi published version to rebuild latest docs for, e.g. v1.26.7"
default: "v1.28.0"
description: "Latest PyPi published version to rebuild latest docs for, e.g. v2.0.0"
default: "v2.0.0"
required: true

jobs:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
name: Deploy cdk stack
name: Deploy CDK Layer v2 stack

permissions:
id-token: write
contents: read

env:
CDK_VERSION: 2.44.0

on:
workflow_call:
inputs:
Expand All @@ -19,6 +22,10 @@ on:
description: "GitHub Environment to use for encrypted secrets"
required: true
type: string
latest_published_version:
description: "Latest version that is published"
required: true
type: string

jobs:
deploy-cdk-stack:
Expand Down Expand Up @@ -82,7 +89,7 @@ jobs:
pip install -r requirements.txt
- name: install cdk and deps
run: |
npm install -g aws-cdk@2.29.0
npm install -g "aws-cdk@$CDK_VERSION"
cdk --version
- name: install deps
run: poetry install
Expand All @@ -94,6 +101,23 @@ jobs:
- name: unzip artefact
run: unzip cdk.out.zip
- name: CDK Deploy Layer
run: cdk deploy --app cdk.out --context region=${{ matrix.region }} 'LayerStack' --require-approval never --verbose
run: cdk deploy --app cdk.out --context region=${{ matrix.region }} 'LayerV2Stack' --require-approval never --verbose --outputs-file cdk-outputs.json
- name: Store latest Layer ARN
if: ${{ inputs.stage == 'PROD' }}
run: |
jq -c '.LayerV2Stack.VersionArn' cdk-outputs.json > cdk-layer-stack-${{ matrix.region }}-layer-version.txt
jq -c '.LayerV2Stack.Arm64VersionArn' cdk-outputs.json >> cdk-layer-stack-${{ matrix.region }}-layer-version.txt
- name: CDK Deploy Canary
run: cdk deploy --app cdk.out --context region=${{ matrix.region}} --parameters DeployStage="${{ inputs.stage }}" 'CanaryStack' --require-approval never --verbose
run: cdk deploy --app cdk.out --context region=${{ matrix.region}} --parameters DeployStage="${{ inputs.stage }}" 'CanaryV2Stack' --require-approval never --verbose
- name: Save Layer ARN artifact
uses: actions/upload-artifacts@v3
with:
name: cdk-layer-stack
path: cdk-layer-stack*

update_v2_layer_arn_docs:
permissions:
contents: write
uses: ./.github/workflows/reusable_update_v2_layer_arn_docs.yml
with:
latest_published_version: ${{ inputs.latest_published_version }}
Loading

0 comments on commit 0bee23c

Please sign in to comment.