From 10fe5e09b124024f7fc358a9c06775653cbaa2f4 Mon Sep 17 00:00:00 2001 From: zhifenglee-aelf Date: Sat, 26 Oct 2024 10:21:12 +0800 Subject: [PATCH] feat(github workflow): removed master restriction when activating actions --- .github/workflows/publish-package-prod.yml | 24 ---------------------- 1 file changed, 24 deletions(-) diff --git a/.github/workflows/publish-package-prod.yml b/.github/workflows/publish-package-prod.yml index f7af733..5e6e682 100644 --- a/.github/workflows/publish-package-prod.yml +++ b/.github/workflows/publish-package-prod.yml @@ -15,46 +15,22 @@ jobs: with: fetch-depth: 0 # Ensure the full history is fetched so we can check the commit history - - name: Verify tag is on master branch - id: verify_tag - run: | - # Get the commit SHA of the tag - TAG_COMMIT=$(git rev-list -n 1 $GITHUB_REF) - # Check if the commit exists on the master branch - if git merge-base --is-ancestor $TAG_COMMIT origin/master; then - echo "Tag commit is on master branch." - echo "IS_ON_MASTER=true" >> $GITHUB_ENV - else - echo "Tag commit is not on master branch." - echo "IS_ON_MASTER=false" >> $GITHUB_ENV - fi - - - name: Stop if not on master - if: env.IS_ON_MASTER != 'true' - run: | - echo "This tag was not created from the master branch. Exiting." - exit 1 - - name: Setup .NET - if: env.IS_ON_MASTER == 'true' uses: actions/setup-dotnet@v1 with: dotnet-version: '8.0.*' # Change this to the .NET version you're using - name: Extract version from tag - if: env.IS_ON_MASTER == 'true' run: | TAG_NAME=$(echo $GITHUB_REF | sed 's/refs\/tags\///') VERSION=${TAG_NAME#v} echo "VERSION=$VERSION" >> $GITHUB_ENV - name: Pack - if: env.IS_ON_MASTER == 'true' working-directory: ${{ env.WORKING_DIRECTORY }} run: dotnet pack --configuration Release --output nupkgs /p:Version=$VERSION - name: Publish NuGet packages - if: env.IS_ON_MASTER == 'true' working-directory: ${{ env.WORKING_DIRECTORY }} run: | dotnet nuget push "nupkgs/*.nupkg" --api-key ${{ secrets.TEMPLATES_NUGET_API_KEY }} --source ${{ vars.TEMPLATES_NUGET_SOURCE_URL }}