Skip to content

Commit

Permalink
Improve release process with automatic publishing of gem into RubyGems
Browse files Browse the repository at this point in the history
  • Loading branch information
Envek committed Feb 5, 2021
1 parent a3eb9a2 commit 8519f4f
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 4 deletions.
32 changes: 28 additions & 4 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,16 @@ jobs:
BODY="${BODY//$'\n'/'%0A'}"
BODY="${BODY//$'\r'/'%0D'}"
echo "::set-output name=body::$BODY"
# Add pre-release option if tag name has any suffix after vMAJOR.MINOR.PATCH
if [[ ${GITHUB_REF#refs/tags/} =~ ^v[0-9]+\.[0-9]+\.[0-9]+.+ ]]; then
echo ::set-output name=prerelease::true
fi
- name: Build gem
run: gem build
- name: Calculate checksums
run: sha256sum yabeda-puma-plugin-${{ steps.tag.outputs.version }}.gem > SHA256SUM
- name: Check version
run: ls yabeda-puma-plugin-${{ steps.tag.outputs.version }}.gem
run: ls -l yabeda-puma-plugin-${{ steps.tag.outputs.version }}.gem
- name: Create Release
id: create_release
uses: actions/create-release@v1
Expand All @@ -45,9 +51,8 @@ jobs:
release_name: ${{ steps.tag.outputs.subject }}
body: ${{ steps.tag.outputs.body }}
draft: false
prerelease: false
- name: Upload Release Asset
id: upload-release-asset
prerelease: ${{ steps.tag.outputs.prerelease }}
- name: Upload built gem as release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -56,3 +61,22 @@ jobs:
asset_path: yabeda-puma-plugin-${{ steps.tag.outputs.version }}.gem
asset_name: yabeda-puma-plugin-${{ steps.tag.outputs.version }}.gem
asset_content_type: application/x-tar
- name: Upload checksums as release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: SHA256SUM
asset_name: SHA256SUM
asset_content_type: text/plain
- name: Publish to GitHub packages
env:
GEM_HOST_API_KEY: Bearer ${{ secrets.GITHUB_TOKEN }}
run: |
gem push yabeda-puma-plugin-${{ steps.tag.outputs.version }}.gem --host https://rubygems.pkg.github.com/${{ github.repository_owner }}
- name: Publish to RubyGems
env:
GEM_HOST_API_KEY: "${{ secrets.RUBYGEMS_API_KEY }}"
run: |
gem push yabeda-puma-plugin-${{ steps.tag.outputs.version }}.gem
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
fail-fast: false
matrix:
include:
- ruby: 3.0
- ruby: 2.7
- ruby: 2.6
- ruby: 2.5
Expand Down
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,38 @@ docker-compose run app bundle exec rspec

Bug reports and pull requests are welcome on GitHub at https://github.com/yabeda-rb/yabeda-puma-plugin.

### Releasing

1. Bump version number in `lib/yabeda/puma/plugin/version.rb`

In case of pre-releases keep in mind [rubygems/rubygems#3086](https://github.com/rubygems/rubygems/issues/3086) and check version with command like `Gem::Version.new(Yabeda::VERSION).to_s`

2. Fill `CHANGELOG.md` with missing changes, add header with version and date.

3. Make a commit:

```sh
git add lib/yabeda/puma/plugin/version.rb CHANGELOG.md
version=$(ruby -r ./lib/yabeda/puma/plugin/version.rb -e "puts Gem::Version.new(Yabeda::Puma::Plugin::VERSION)")
git commit --message="${version}: " --edit
```

4. Create annotated tag:

```sh
git tag v${version} --annotate --message="${version}: " --edit --sign
```

5. Fill version name into subject line and (optionally) some description (list of changes will be taken from changelog and appended automatically)

6. Push it:

```sh
git push --follow-tags
```

7. GitHub Actions will create a new release, build and push gem into RubyGems! You're done!

## License

The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).

0 comments on commit 8519f4f

Please sign in to comment.