-
Notifications
You must be signed in to change notification settings - Fork 18
67 lines (53 loc) · 1.96 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
59
60
61
62
63
64
65
66
67
name: release
on:
workflow_dispatch:
push:
branches:
- main
paths:
- lib/version.rb
permissions:
contents: write
packages: write
id-token: write
attestations: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- uses: ruby/setup-ruby@1198b074305f9356bd56dd4b311757cc0dab2f1c # [email protected]
with:
bundler-cache: true
- name: bootstrap
run: script/bootstrap
- name: lint
run: bundle exec rubocop -c .rubocop.yml lib/ spec/
- name: test
run: script/test
- name: set GEM_NAME from gemspec
run: echo "GEM_NAME=$(ls | grep gemspec | cut -d. -f1)" >> $GITHUB_ENV
# builds the gem and saves the version to GITHUB_ENV
- name: build
run: echo "GEM_VERSION=$(gem build ${{ env.GEM_NAME }}.gemspec 2>&1 | grep Version | cut -d':' -f 2 | tr -d " \t\n\r")" >> $GITHUB_ENV
- uses: actions/attest-build-provenance@v1
with:
subject-path: "${{ env.GEM_NAME }}-${{ env.GEM_VERSION }}.gem"
- name: publish to GitHub packages
run: |
export OWNER=$( echo ${{ github.repository }} | cut -d "/" -f 1 )
GEM_HOST_API_KEY=${{ secrets.GITHUB_TOKEN }} gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} ${{ env.GEM_NAME }}-${{ env.GEM_VERSION }}.gem
- name: release
uses: ncipollo/release-action@a2e71bdd4e7dab70ca26a852f29600c98b33153e # [email protected]
with:
artifacts: "${{ env.GEM_NAME }}-${{ env.GEM_VERSION }}.gem"
tag: "v${{ env.GEM_VERSION }}"
generateReleaseNotes: true
- name: Publish to RubyGems
run: |
mkdir -p ~/.gem
echo -e "---\n:rubygems_api_key: ${{ secrets.RUBYGEMS_API_KEY }}" > ~/.gem/credentials
chmod 0600 ~/.gem/credentials
gem push ${{ env.GEM_NAME }}-${{ env.GEM_VERSION }}.gem
rm ~/.gem/credentials