-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (55 loc) · 1.75 KB
/
release.yml
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
name: release
on:
push:
branches:
- main
- master
pull_request:
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: go-semantic-release/action@v1
with:
allow-initial-development-versions: true
github-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: check if tag has been created
run: test -n "$(git tag --points-at HEAD)" && echo "PUBLISH=true" >> $GITHUB_ENV || echo "PUBLISH=false" >> $GITHUB_ENV
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2
- run: bundle install
- run: gem build *.gemspec
if: ${{ env.PUBLISH != "true" }}
- run: gem build *.gemspec
if: ${{ env.PUBLISH == "true" }}
env:
CI_COMMIT_TAG: ${{github.ref_name}}
- name: prepare gem credential
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
- name: publish to GPR
if: ${{ env.PUBLISH == "true" }}
run: |
printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
env:
GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
OWNER: ${{ github.repository_owner }}
- name: publish to RubyGems
if: ${{ env.PUBLISH == "true" }}
run: |
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
gem push *.gem
env:
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"