Skip to content

Publish

Publish #338

Workflow file for this run

name: Publish
on:
schedule:
- cron: '0 6 * * *'
workflow_dispatch:
inputs:
no_skip_when_current:
default: false
type: boolean
description: |
Create a new release even if one already
exists for the current version of the CDK.
jobs:
should-proceed:
name: Should proceed?
runs-on: ubuntu-22.04
outputs:
proceed: ${{ steps.main.outputs.proceed == 'true' }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: pip
- id: main
env:
GH_TOKEN: ${{ github.token }}
run: |
if [[ "${{ inputs.no_skip_when_current }}" == "true" ]]; then
1>&2 echo "proceed!"
echo "proceed=true" >> $GITHUB_OUTPUT
exit 0
fi
latest_release_tag=$( \
gh release view \
--repo=$GITHUB_REPOSITORY \
--json tagName \
| jq -r .tagName
)
latest_release_cdk_version=$( \
echo $latest_release_tag \
| sed -En 's ^v([^-]+)-[0-9]+$ \1 p' \
)
make .build/latest/cdk-version
current_cdk_version=$(cat .build/latest/cdk-version)
1>&2 echo "latest release tag: $latest_release_tag"
1>&2 echo "latest release cdk version: $latest_release_cdk_version"
1>&2 echo "current cdk version: $current_cdk_version"
if [[ "$latest_release_cdk_version" != "$current_cdk_version" ]]; then
1>&2 echo "proceed!"
echo "proceed=true" >> $GITHUB_OUTPUT
else
1>&2 echo "skip!"
echo "proceed=false" >> $GITHUB_OUTPUT
fi
docset:
if: ${{ needs.should-proceed.outputs.proceed == 'true' }}
name: Docset
needs: should-proceed
uses: ./.github/workflows/docset.yml
create-release:
name: Create Release
needs: docset
runs-on: ubuntu-22.04
permissions:
actions: read
contents: read
env:
GH_TOKEN: ${{ github.token }}
steps:
- uses: actions/download-artifact@v3
with:
name: AWS-CDK.tgz
- name: Extract docset version
run: |
tar \
--extract \
--file=AWS-CDK.tgz \
--strip-components=4 \
AWS-CDK.docset/Contents/Resources/Documents/cdk-version
- name: Create new release
env:
GH_TOKEN: ${{ secrets.PAT }}
run: |
tag="v$(cat cdk-version)-$(date +%s)"
gh release create \
--repo=$GITHUB_REPOSITORY \
--target=$GITHUB_SHA \
--title=$tag \
--notes="CDK $(cat cdk-version)" \
--latest \
"$tag" \
AWS-CDK.tgz