-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
152 additions
and
28 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 |
---|---|---|
@@ -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 | ||
|
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 |
---|---|---|
@@ -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 ---------------------------------------- | ||
|
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 |
---|---|---|
@@ -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" |
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 |
---|---|---|
@@ -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" |
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 |
---|---|---|
|
@@ -71,3 +71,4 @@ gemfiles/*.lock | |
node_modules | ||
sorbet/rbi | ||
|
||
/release_changelog.md |
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