Skip to content

Commit

Permalink
Update workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
bonnie57 committed Nov 13, 2024
1 parent 7a1ee60 commit fa834f2
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 2 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/publish-package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,7 @@ jobs:
]
# Skip this job if core-sdk doesn't need to be published
# and the event triggering the workflow is a push
if: ${{ github.event_name == 'push' && needs.check_if_version_is_valid_for_branch.outputs.IS_PUBLISH_CORE_SDK == 'true'}}
uses: storyprotocol/gha-workflows/.github/workflows/reusable-create-release.yml@main
uses: ./.github/workflows/reusable-create-release.yml@main
with:
tag_name: core-sdk@${{ needs.print_version_to_publish.outputs.core_sdk_version_to_be_published }}

Expand Down
54 changes: 54 additions & 0 deletions .github/workflows/reusable-create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Reusable workflow to create release in GitHub

on:
workflow_call:
inputs:
tag_name:
type: string
required: true
description: "Tag name to be published"

permissions:
contents: write
actions: write

jobs:
release:
# if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5

- name: Retrieve Previous Tag Before Creating New Tag
id: get_previous_tag
run: |
git fetch --tags
# Get the last tag from the list of tags sorted by creation date
LATEST_TAG=$(git tag --sort=creatordate | tail -n1)
echo "The latest tag based on creation date is $LATEST_TAG"
echo "fromTag=$LATEST_TAG" >> $GITHUB_ENV
- name: Tag and Push
id: tag_and_push
run: |
TAG_NAME=${{ inputs.tag_name}}
git config --global user.name 'GitHub Actions'
git config --global user.email 'actions@github.com'
git tag -a $TAG_NAME -m "Release $TAG_NAME"
git push origin $TAG_NAME
echo "toTag=$TAG_NAME" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build Changelog
id: build_changelog
uses: mikepenz/release-changelog-builder-action@1eff87d3e9087a5d44e572b4c431e500dd2124f8
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create Release
uses: mikepenz/action-gh-release@a74c6b72af54cfa997e81df42d94703d6313a2d0 #softprops/action-gh-release
with:
tag_name: ${{ inputs.tag_name }}
body: ${{ steps.build_changelog.outputs.changelog }}

0 comments on commit fa834f2

Please sign in to comment.