-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use RubyGems trusted publisher protocol when publishing (#28)
* use rubygems trusted publisher protocol when publishing * move permissions down to the job level
- Loading branch information
1 parent
727dab8
commit 31e66a4
Showing
1 changed file
with
18 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,51 +3,49 @@ name: Publish Gem | |
on: | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
build_and_publish: | ||
name: Build, tag & publish | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
id-token: write | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: 3.2.1 | ||
bundler-cache: true | ||
|
||
- name: Get version | ||
id: version | ||
run: | | ||
VERSION=$(ruby -e "require './lib/tip_tap/version'; puts TipTap::VERSION") | ||
echo "::set-output name=version::$VERSION" | ||
echo "version=$VERSION" >> $GITHUB_OUTPUT | ||
- name: Create and push tag | ||
- name: Create tag | ||
run: | | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "GitHub Action" | ||
git tag v${{ steps.version.outputs.version }} | ||
git push origin v${{ steps.version.outputs.version }} | ||
- name: Push tag | ||
run: git push origin v${{ steps.version.outputs.version }} | ||
|
||
- name: Install dependencies | ||
run: bundle install | ||
|
||
- name: Run tests | ||
run: | | ||
bundle install | ||
bundle exec rspec | ||
run: bundle exec rspec | ||
|
||
- name: Build and publish to RubyGems | ||
run: | | ||
mkdir -p $HOME/.gem | ||
touch $HOME/.gem/credentials | ||
chmod 0600 $HOME/.gem/credentials | ||
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials | ||
gem build *.gemspec | ||
gem push *.gem | ||
env: | ||
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_API_KEY}}" | ||
- name: Publish to RubyGems | ||
uses: rubygems/release-gem@v1 | ||
|
||
- name: Create GitHub Release | ||
uses: actions/create-release@v1 | ||
|