Skip to content

Commit

Permalink
Release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdan committed Dec 8, 2024
1 parent 25f9213 commit fa23d75
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 28 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Publish RubyGem

on:
workflow_dispatch: # Trigger the workflow manually
inputs:
otp_code:
description: 'Enter the RubyGems OTP code'
required: true
type: string

permissions:
contents: write

jobs:
release:
runs-on: ubuntu-latest

steps:

- name: Checkout code
uses: actions/checkout@v3

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3.4'

- name: Extract Gem Version
id: extract_version
run: |
VERSION=$(./.github/workflows/scripts/version.sh)
echo "Version: $VERSION"
echo "gem_version=$VERSION" >> $GITHUB_ENV
- name: Install dependencies
run: bundle install

- name: Extract Changelog
run: ./.github/workflows/scripts/changelog.sh

- name: Build the gem
run: gem build *.gemspec

- name: Tag the release version
run: ./.github/workflows/scripts/tag.sh

- name: Publish to RubyGems
env:
GEM_HOST_API_KEY: ${{ secrets.JS_ROUTES_RUBYGEMS_KEY }}
run: |
gem push *.gem --otp ${{ github.event.inputs.otp_code }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: "v${{ env.gem_version }}"
tag_name: "v${{ env.gem_version }}"
body_path: ./release_changelog.md
draft: false
prerelease: false

32 changes: 32 additions & 0 deletions .github/workflows/scripts/changelog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh

set -e

CHANGELOG="CHANGELOG.md"
OUTPUT="./release_changelog.md"
SCRIPT_DIR=$(dirname "$(realpath "$0")")
VERSION=$($SCRIPT_DIR/version.sh)

if [ -z "$VERSION" ]; then
echo "VERSION is not specified"
exit 1
fi

if [ ! -f "$CHANGELOG" ]; then
echo "CHANGELOG.md file not found!"
exit 1
fi

if ! grep -q "^## \[$VERSION\]" $CHANGELOG; then
echo "No changelog found for version $VERSION in $CHANGELOG"
exit 1
fi

echo "## Changes" > $OUTPUT
echo "" >> $OUTPUT
ruby -e "puts File.read('$CHANGELOG').split('## [$VERSION]')[1]&.split('## ')&.first&.strip" >> $OUTPUT
echo "Release notes:"
echo ----------------------------------------
cat $OUTPUT
echo ----------------------------------------

8 changes: 8 additions & 0 deletions .github/workflows/scripts/tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

set -e
SCRIPT_DIR=$(dirname "$(realpath "$0")")
VERSION=$($SCRIPT_DIR/version.sh)

git tag "v$VERSION" || echo "Tag already exists."
git push origin "v$VERSION"
18 changes: 18 additions & 0 deletions .github/workflows/scripts/version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

set -e

VERSION_FILE="./lib/js_routes/version.rb"
if [ ! -f "$VERSION_FILE" ]; then
echo "Version file not found!"
exit 1
fi

VERSION=$(ruby -r $VERSION_FILE -e "puts JsRoutes::VERSION")

if [ -z "$VERSION" ]; then
echo "Could not extract version from $VERSION_FILE"
exit 1
fi

echo "$VERSION"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,4 @@ gemfiles/*.lock
node_modules
sorbet/rbi

/release_changelog.md
60 changes: 32 additions & 28 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog

## v2.3.3
## [2.3.4]

* Migrate to yarn 4

## [2.3.3]

* Rework default banner to use `routes.rb` digest instead of timestamp to ensure
consistent routes.js version accross environments.
Expand All @@ -17,7 +21,7 @@ The new default banner:
*/
```

## v2.3.2
## [2.3.2]

* Add `banner` option that allow to control JSDoc on top of generated file. [#324](https://github.com/bogdan/repo/issues/324).

Expand All @@ -34,131 +38,131 @@ JsRoutes.setup do |c|
end
```

## v2.3.1
## [2.3.1]

* Add timestamp on when routes.js was generated into banner.
* Fix application specified directly without proc. [#323](https://github.com/railsware/js-routes/issues/323)
* Support `optional_definition_params` option. See [Related Docs](./Readme.md#optional-definition-params).

## v2.3.0
## [2.3.0]

* Drop support of Rails 4.x
* Fix support of shakapacker [#321](https://github.com/railsware/js-routes/issues/321).
* Fix support for Rails 8 [#319](https://github.com/railsware/js-routes/issues/319)
* Deprecated `rake js:routes:typescript`.
`rake js:routes` now automatically detects if types support can be used on not.

## v2.2.10
## [2.2.10]

* Remove sorbet files from repo
* Clearly define files included in gem
* Fix Middleware and Middleware generator bugs [#316](https://github.com/railsware/js-routes/issues/316)
* Remove empty object linter warning on DTS module
* Generators: Add `.ts` extension when searching for main JS file of the project

## v2.2.9
## [2.2.9]

* Fix middleware error for non-modern setup.
* Added [Sorbet](https://sorbet.org/) method signatures.
* Always use DTS module type when calling JsRoutes.definitions or .definitions!.
[#313](https://github.com/railsware/js-routes/issues/313)

## v2.2.8
## [2.2.8]

* Leave emoji symbols intact when encoding URI fragment [#312](https://github.com/railsware/js-routes/issues/312)
* Use webpacker config variable instead of hardcode [#309](https://github.com/railsware/js-routes/issues/309)
* Use `File.exist?` to be compatible with all versions of ruby [#310](https://github.com/railsware/js-routes/issues/310)

## v2.2.7
## [2.2.7]

* Fix ESM Tree Shaking [#306](https://github.com/railsware/js-routes/issues/306)

## v2.2.6
## [2.2.6]

* Prefer to extend `javascript:build` instead of `assets:precompile`. [#305](https://github.com/railsware/js-routes/issues/305)
* Add stimulus framework application.js location to generators

## v2.2.5
## [2.2.5]

* Upgraded eslint and prettier versions [#304](https://github.com/railsware/js-routes/issues/304)
* Fix middleware generator [#300](https://github.com/railsware/js-routes/issues/300)
* Support `params` special parameter

## v2.2.4
## [2.2.4]

* Fix rails engine loading if sprockets is not in Gemfile. Fixes [#294](https://github.com/railsware/js-routes/issues/294)

## v2.2.3
## [2.2.3]

* Fixed NIL module type namespace defintion [#297](https://github.com/railsware/js-routes/issues/297).
* The patch may cause a problem with nested `namespace` option.
* Ex. Value like `MyProject.Routes` requires to define `window.MyProject` before importing the routes file

## v2.2.2
## [2.2.2]

* Fix custom file path [#295](https://github.com/railsware/js-routes/issues/295)

## v2.2.1
## [2.2.1]

* Improve generator to update route files on `assets:precompile` and add them to `.gitignore by default` [#288](https://github.com/railsware/js-routes/issues/288#issuecomment-1012182815)

## v2.2.0
## [2.2.0]

* Use Rack Middleware to automatically update routes file in development [#288](https://github.com/railsware/js-routes/issues/288)
* This setup is now a default recommended due to lack of any downside comparing to [ERB Loader](./Readme.md#webpacker) and [Manual Setup](./Readme.md#advanced-setup)

## v2.1.3
## [2.1.3]

* Fix `default_url_options` bug. [#290](https://github.com/railsware/js-routes/issues/290)

## v2.1.2
## [2.1.2]

* Improve browser window object detection. [#287](https://github.com/railsware/js-routes/issues/287)

## v2.1.1
## [2.1.1]

* Added webpacker generator `./bin/rails generate js_routes:webpacker`
* Reorganized Readme to describe different setups with their pros and cons more clearly

## v2.1.0
## [2.1.0]

* Support typescript defintions file aka `routes.d.ts`. See [Readme.md](./Readme.md#definitions) for more information.

## v2.0.8
## [2.0.8]

* Forbid usage of `namespace` option if `module_type` is not `nil`. [#281](https://github.com/railsware/js-routes/issues/281).

## v2.0.7
## [2.0.7]

* Remove source map annotation from JS file. Fixes [#277](https://github.com/railsware/js-routes/issues/277)
* Generated file is not minified, so it is better to use app side bundler/compressor for source maps


## v2.0.6
## [2.0.6]

* Disable `namespace` option default for all envs [#278](https://github.com/railsware/js-routes/issues/278)

## v2.0.5
## [2.0.5]

* Fixed backward compatibility issue [#276](https://github.com/railsware/js-routes/issues/276)

## v2.0.4
## [2.0.4]

* Fixed backward compatibility issue [#275](https://github.com/railsware/js-routes/issues/275)

## v2.0.3
## [2.0.3]

* Fixed backward compatibility issue [#275](https://github.com/railsware/js-routes/issues/275)

## v2.0.2
## [2.0.2]

* Fixed backward compatibility issue [#274](https://github.com/railsware/js-routes/issues/274)

## v2.0.1
## [2.0.1]

* Fixed backward compatibility issue [#272](https://github.com/railsware/js-routes/issues/272)

## v2.0.0
## [2.0.0]

Version 2.0 has some breaking changes.
See [UPGRADE TO 2.0](./VERSION_2_UPGRADE.md) for guidance.
Expand Down

0 comments on commit fa23d75

Please sign in to comment.