-
Notifications
You must be signed in to change notification settings - Fork 2
66 lines (59 loc) · 1.59 KB
/
gem-push.yml
File metadata and controls
66 lines (59 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: Ruby Gem
on:
push:
branches: [ "main" ]
jobs:
test:
uses: ./.github/workflows/test.yml
check:
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
tag_name: ${{ steps.get_tag.outputs.TAG_NAME }}
steps:
- uses: actions/checkout@v4
- id: get_tag
name: Get Local Tag Name
run: |
TAG_NAME=$(ruby -I. -r lib/restful_error/version -e 'puts "v#{RestfulError::VERSION}"')
if git fetch --depth 1 origin tag $TAG_NAME; then
echo "::notice::$TAG_NAME already released. skip publishing."
exit 0
fi
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_OUTPUT
build:
needs:
- test
- check
if: needs.check.outputs.tag_name
env:
TAG_NAME: ${{ needs.check.outputs.tag_name }}
name: Build + Publish
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- uses: actions/checkout@v4
- name: Set up Ruby 3.3
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3
- name: build
run: gem build *.gemspec
- name: Publish to RubyGems
run: gem push *.gem
env:
GEM_HOST_API_KEY: ${{ secrets.GEM_HOST_API_KEY }}
- name: Publish to GPR
run: gem push --host https://rubygems.pkg.github.com/${OWNER} *.gem
env:
OWNER: ${{ github.repository_owner }}
GEM_HOST_API_KEY: ${{ secrets.GITHUB_TOKEN }}
- name: Create Tag
run: |
git config user.email "o@kbn.one"
git config user.name "github action"
git tag $TAG_NAME
git push origin $TAG_NAME