Skip to content

Commit

Permalink
chore: fix name,desc,author (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
pgollucci authored Nov 2, 2024
1 parent 03c3f38 commit f40120f
Show file tree
Hide file tree
Showing 3 changed files with 156 additions and 3 deletions.
6 changes: 3 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: "Release Composite Action"
description: "P6 Action: Release a CDK Construct"
author: "p6m7g8"
name: "P6 GHA: Releases and Publishes a CDK Construct to NPMJS, PYPI, Nuget, GoLang, Maven"
description: "P6 GHA: Releases and Publishes a CDK Construct to NPMJS, PYPI, Nuget, GoLang, Maven"
author: "Philip M. Gollucci"
inputs:
aws_region:
description: "AWS region for deployment"
Expand Down
6 changes: 6 additions & 0 deletions cdk-consruct-release/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"cSpell.words": [
"elif",
"releasetag"
]
}
147 changes: 147 additions & 0 deletions cdk-consruct-release/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
name: "Release Composite Action"
description: "P6 Action: Release a CDK Construct"
author: "p6m7g8"
inputs:
aws_region:
description: "AWS region for deployment"
required: false
default: "us-east-1"
aws_role:
description: "AWS role to assume"
required: true
aws_session_name:
description: "Session name for the AWS role"
required: true
cdk_deploy_account:
description: "AWS CDK deploy account"
required: true
cdk_deploy_region:
description: "AWS CDK deploy region"
required: true
npm_token:
description: "NPM token"
required: true
twine_username:
description: "Twine username"
required: true
twine_password:
description: "Twine password"
required: true
nuget_api_key:
description: "Nugget API key"
required: true
go_github_token:
description: "GoThub token"
required: true
p6_a_gh_token:
description: "GitHub token"
required: true
runs:
using: "composite"
steps:
- name: Checkout code
if: ${{ !contains(github.event.head_commit.message, 'chore(release):') }}
uses: actions/checkout@v4.2.2
with:
fetch-depth: 0
- name: Bump Version
id: bump
if: ${{ !contains(github.event.head_commit.message, 'chore(release):') }}
shell: bash
run: |
latest_tag=$(git tag --list "v*" --sort=-v:refname | head -1)
log_lines=$(git log $latest_tag..HEAD --pretty="format:- %s")
major=$(echo $latest_tag | cut -d. -f1)
minor=$(echo $latest_tag | cut -d. -f2)
patch=$(echo $latest_tag | cut -d. -f3)
if echo "$log_lines" | grep -q "BREAKING CHANGE"; then
major=$((major + 1))
minor=0
patch=0
elif echo "$log_lines" | grep -q "major"; then
major=$((major + 1))
minor=0
patch=0
elif echo "$log_lines" | grep -q "feat"; then
minor=$((minor + 1))
patch=0
elif echo "$log_lines" | grep -q "fix"; then
patch=$((patch + 1))
elif echo "$log_lines" | grep -v "chore(release):" | grep -q "chore"; then
patch=$((patch + 1))
else
true
fi
new_tag="$major.$minor.$patch"
npm version $new_tag --no-git-tag-version
mkdir -p dist/
echo $new_tag >dist/releasetag.txt
echo "$log_lines" | grep -v "chore(release):" >dist/changelog.md
echo "Semantic version tag: $latest_tag -> $new_tag"
echo "ChangeLog:"
cat dist/changelog.md
if grep -E "^- (chore|fix|feat|major)\!*" dist/changelog.md; then
echo "bump=true" >> $GITHUB_OUTPUT
else
echo "bump=false" >> $GITHUB_OUTPUT
fi
- name: Github Release
if: ${{ steps.bump.outputs.bump == 'true' }}
shell: bash
env:
GITHUB_TOKEN: ${{ inputs.p6_a_gh_token }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_REF: ${{ github.ref }}
run: |
set -x
tag_name=$(cat dist/releasetag.txt)
if gh release view "$tag_nameE" -R "$GITHUB_REPOSITORY" > /dev/null 2>&1; then
echo "Release with tag $tag_name already exists. Skipping release creation."
else
gh release create "$tag_name" -R "$GITHUB_REPOSITORY" -F dist/changelog.md -t "$tag_name" --target "$GITHUB_REF"
echo "Release with tag $tag_name created successfully."
fi
- name: CDK Build
if: ${{ steps.bump.outputs.bump == 'true' }}
uses: p6m7g8-actions/cdk-construct-build@main
with:
aws_region: ${{ inputs.cdk_deploy_region }}
aws_role: ${{ inputs.aws_role }}
aws_session_name: ${{ inputs.aws_session_name }}
cdk_deploy_account: ${{ inputs.cdk_deploy_account }}
cdk_deploy_region: ${{ inputs.cdk_deploy_region }}
- name: Publish to NPM
if: ${{ steps.bump.outputs.bump == 'true' }} && contains(github.event.head_commit.message, 'chore(release):')
shell: bash
env:
NPM_TOKEN: ${{ inputs.npm_token }}
run: yarn run publish:npm
- name: Publish to PYPI
env:
TWINE_USERNAME: ${{ inputs.twine_username }}
TWINE_PASSWORD: ${{ inputs.twine_password }}
if: ${{ steps.bump.outputs.bump == 'true' }} && contains(github.event.head_commit.message, 'chore(release):')
shell: bash
run: yarn run publish:pypi
- name: Publish to Nuget
env:
NUGET_API_KEY: ${{ inputs.nuget_api_key }}
if: ${{ steps.bump.outputs.bump == 'true' }} && contains(github.event.head_commit.message, 'chore(release):')
shell: bash
run: yarn run publish:nuget
- name: Publish to GoLang
if: ${{ steps.bump.outputs.bump == 'true' }} && contains(github.event.head_commit.message, 'chore(release):')
shell: bash
env:
GIT_USER_NAME: ${{ github.actor }}
GIT_USER_EMAIL: ${{ github.actor }}@users.noreply.github.com
GH_TOKEN: ${{ inputs.go_github_token }}
GITHUB_TOKEN: ${{ inputs.go_github_token }}
run: |
git config --global user.name "$GIT_USER_NAME"
git config --global user.email "$GIT_USER_EMAIL"
git remote set-url origin "https://$GH_TOKEN@github.com/$GITHUB_REPOSITORY.git"
yarn run publish:golang

0 comments on commit f40120f

Please sign in to comment.