Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate publish #339

Merged
merged 2 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Publish package to the RubyGems.org
on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: 'The version to release. v prefix is required (e.g. v1.10.0)'
required: true

jobs:
push:
name: Push gem to RubyGems.org
runs-on: ubuntu-latest

permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
contents: write # IMPORTANT: this permission is required for `rake release` to push the release tag

steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: 3.3
- name: Update version file with the release version
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
VERSION=${{ github.event.inputs.version }}
else
VERSION=${{ github.event.release.tag_name }}
fi
VERSION=${VERSION#v}

sed -i "s/VERSION = \".*\"/VERSION = \"$VERSION\"/" lib/line/bot/api/version.rb
Comment on lines +26 to +35
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This step is to avoid editing file to update version manually (

)


cat lib/line/bot/api/version.rb
- uses: rubygems/release-gem@v1
10 changes: 10 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,13 @@ require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)

task default: :spec

# We don't want to push tags to source control when releasing the gem
Rake::Task["release"].clear

# Redefine `release` task to build and push gem to RubyGems without pushing to source control
## https://github.com/rubygems/bundler/blob/35be6d9a603084f719fec4f4028c18860def07f6/lib/bundler/gem_helper.rb#L53-L57
desc "Build and push gem to RubyGems without pushing to source control"
task "release", [:remote] => ["build", "release:guard_clean", "release:rubygem_push"] do
puts "Built and pushed gem to RubyGems without pushing to source control."
end