Skip to content

Commit

Permalink
Testing with new shared action release
Browse files Browse the repository at this point in the history
  • Loading branch information
OmOmofonmwan committed Nov 25, 2024
1 parent 228325f commit db60867
Showing 1 changed file with 6 additions and 74 deletions.
80 changes: 6 additions & 74 deletions .github/workflows/shared_action_release.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Release Workflow

run-name: "Releasing ${{ github.event.repository.name }} #${{github.run_number}}"
run-name: "[${{inputs.release_type}}] Releasing ${{ github.event.repository.name }} #${{github.run_number}}"

# Trigger workflow manually
on:
Expand Down Expand Up @@ -39,77 +39,9 @@ jobs:
echo "ERROR: Attempting to release from branch ${{env.BRANCH_NAME}}. Release from ${{env.TRUNK_BRANCH_NAME}} branch only"
exit 1
- name: Checkout Code
uses: actions/checkout@v4.2.2
- name: "[${{inputs.release_type}}] Release Shared Action"
uses: ikmdev/git-shared-action-release-action@main
with:
token: ${{secrets.IKMDEVOPS_PAT_TOKEN}}
fetch-depth: 0

- name: Get Latest Release Tag
id: getLatestTag
run: |
git fetch --tags
TAG=$(git describe --tags `git rev-list --tags --max-count=1`)
echo "TAG: " $TAG
if [ $TAG == '' ]; then
echo "LATEST_TAG=0.0.0" >> $GITHUB_OUTPUT
else
echo "LATEST_TAG=$(echo "$TAG" | sed "s/v//")" >> $GITHUB_OUTPUT
fi
echo "LATEST_TAG: ${LATEST_TAG}"
- name: Split Tag String
uses: xom9ikk/split@v1.1
id: splitTagString
with:
string: ${{steps.getLatestTag.outputs.LATEST_TAG}}
separator: .
limit: -1

- name: "[${{inputs.release_type}}] Increment Tag Version"
id: incrementedTagVersion
run: |
if [ $RELEASE_TYPE == 'Major' ]; then
echo "NEW_RELEASE_TAG=$(($MAJOR_STRING + 1)).0.0" >> $GITHUB_OUTPUT
elif [ $RELEASE_TYPE == 'Minor' ]; then
echo "NEW_RELEASE_TAG=${MAJOR_STRING}.$(($MINOR_STRING + 1)).0" >> $GITHUB_OUTPUT
else
echo "NEW_RELEASE_TAG=${MAJOR_STRING}.${MINOR_STRING}.$(($PATCH_STRING + 1))" >> $GITHUB_OUTPUT
fi
env:
RELEASE_TYPE: ${{inputs.release_type}}
MAJOR_STRING: ${{steps.splitTagString.outputs._0}}
MINOR_STRING: ${{steps.splitTagString.outputs._1}}
PATCH_STRING: ${{steps.splitTagString.outputs._2}}

- name: "[${{inputs.release_type}}] Create & Push Tag -- ${{steps.incrementedTagVersion.outputs.NEW_RELEASE_TAG}}"
run: |
git remote set-url origin https://git:${{secrets.IKMDEVOPS_PAT_TOKEN}}@github.com/${{github.repository}}.git
git pull -p
git config user.name "ikmdevops"
git config user.email devops@ikm.dev
git tag -a v$NEW_RELEASE_TAG -m"Release Version $NEW_RELEASE_TAG"
git push --tags origin
env:
NEW_RELEASE_TAG: ${{steps.incrementedTagVersion.outputs.NEW_RELEASE_TAG}}

- name: "[${{inputs.release_type}}] Create Release -- ${{steps.incrementedTagVersion.outputs.NEW_RELEASE_TAG}}"
run: |
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{github.repository}}/releases \
-d '{"tag_name":"v${{steps.incrementedTagVersion.outputs.NEW_RELEASE_TAG}}","name":"v${{steps.incrementedTagVersion.outputs.NEW_RELEASE_TAG}}","body":"Release v${{steps.incrementedTagVersion.outputs.NEW_RELEASE_TAG}}","draft":false,"prerelease":false,"generate_release_notes":false}'
ikmdevops_pat: ${{secrets.IKMDEVOPS_PAT_TOKEN}}
github_token: ${{secrets.GITHUB_TOKEN}}
release_type: ${{inputs.release_type}}

0 comments on commit db60867

Please sign in to comment.