1717
1818 steps :
1919 - uses : actions/checkout@v4
20+ with :
21+ fetch-tags : ' true'
2022 - name : Set up Ruby 3.3
2123 uses : ruby/setup-ruby@v1
2224 with :
@@ -27,35 +29,42 @@ jobs:
2729 TAG_NAME=$(ruby -I. -r lib/restful_error/version -e 'puts "v#{RestfulError::VERSION}"')
2830 echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
2931
30- - name : Check already released
32+ - id : check
33+ name : Check already released
3134 run : |
32- if git tag | grep -q $TAG_NAME; then
35+ if git fetch --depth 1 origin tag $TAG_NAME; then
3336 echo "$TAG_NAME already released. skip."
3437 exit 0
3538 fi
39+ echo "deploy=true" >> $GITHUB_OUTPUT
3640
3741 - name : build
42+ if : steps.check.outputs.deploy == 'true'
3843 run : gem build *.gemspec
3944
4045 - name : Publish to RubyGems
46+ if : steps.check.outputs.deploy == 'true'
4147 run : gem push *.gem
4248 env :
4349 GEM_HOST_API_KEY : ${{ secrets.GEM_HOST_API_KEY }}
4450
4551 - name : Publish to GPR
52+ if : steps.check.outputs.deploy == 'true'
4653 run : gem push --host https://rubygems.pkg.github.com/${OWNER} *.gem
4754 env :
4855 OWNER : ${{ github.repository_owner }}
4956 GEM_HOST_API_KEY : ${{ secrets.GITHUB_TOKEN }}
5057
5158 - name : Create Tag
59+ if : steps.check.outputs.deploy == 'true'
5260 run : |
5361 git config user.email "o@kbn.one"
5462 git config user.name "github action"
5563 git tag $TAG_NAME
5664 git push origin $TAG_NAME
5765
5866 - name : Create Release
67+ if : steps.check.outputs.deploy == 'true'
5968 uses : actions/create-release@v1
6069 env :
6170 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments