Skip to content

Commit

Permalink
NPM + Ruby Gem Alpha Release (#2366)
Browse files Browse the repository at this point in the history
#### Breaking Changes

No

#### Runway Ticket URL
https://nitro.powerhrg.com/runway/backlog_items/PLAY-593

#### How to test this
Add an alpha label to our releases and see if it releases to npm and
ruby gems.

#### Checklist:

- [X] **LABELS** Add a label: `enhancement`, `bug`, `improvement`, `new
kit`, `deprecated`, or `breaking`. See [Changelog &
Labels](https://github.com/powerhome/playbook/wiki/Changelog-&-Labels)
for details.
- [ ] **DEPLOY** Please add the `Milano` label when you are ready for a
review.
- [ ] **SCREENSHOT** Please add a screen shot or two.
- [ ] **SPECS** Please cover your changes with specs.
- [ ] **READ DOCS** Please make sure you have read and understand the
[Playbook Release
Process](https://github.com/powerhome/playbook/wiki/Playbook-Releases)
  • Loading branch information
jasperfurniss authored Mar 14, 2023
1 parent 6da8a36 commit e0fcd86
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 2 deletions.
74 changes: 72 additions & 2 deletions .github/workflows/github-actions-alpha-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,79 @@ run-name: ${{ github.actor }} is creating an Alpha Version 🚀
on:
pull_request:
types: [ labeled ]
labels:
- alpha
jobs:
Creating-Alpha-Version:
if: github.event.label.name == 'alpha'
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./playbook
env:
# Set an environment variable for the branch name
BRANCH_NAME: ${{ github.head_ref }}
FONTAWESOME_NPM_AUTH_TOKEN: ${{ secrets.FONTAWESOME_NPM_AUTH_TOKEN }}
GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
steps:
- run: echo "🎉 Hello Alpha"
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 14
registry-url: 'https://registry.npmjs.org'
- name: Ruby Setup
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Python Setup
uses: actions/setup-python@v4
with:
python-version: '2.7'
- name: Set Git Config
run: |
git config --local user.name "${{ github.actor }}"
git config --local user.email "${{ github.actor }}@users.noreply.github.com"
- name: Grab Current Version
run: |
playbook_npm_version=$(node -pe "require('./package.json').version")
echo "playbook_npm_version=${playbook_npm_version}" >> $GITHUB_ENV
playbook_ruby_version=$(ruby -r ./lib/playbook/version.rb -e "puts Playbook::VERSION")
echo "playbook_ruby_version=${playbook_ruby_version}" >> $GITHUB_ENV
- name: Set New Alpha Version
id: grab-package-version
run: |
formatted_branch=$(echo "${{ env.BRANCH_NAME }}" | tr -cd '[:alnum:]')
npm_alpha_version="${{ env.playbook_npm_version }}-alpha.${formatted_branch}${{ github.run_number }}"
ruby_alpha_version="${{ env.playbook_ruby_version }}.pre.alpha.${formatted_branch}${{ github.run_number }}"
echo "new_npm_alpha_version=${npm_alpha_version}" >> $GITHUB_ENV
echo "new_ruby_alpha_version=${ruby_alpha_version}" >> $GITHUB_ENV
- name: Update Version.rb
id: update-version-rb
run: |
gem install bundler
bundle
bin/rails pb_release:action[${{env.new_ruby_alpha_version}}]
- name: Version Up, Distribute and Publish
run: |
yarn install
yarn version --new-version ${{ env.new_npm_alpha_version }}
bundle
yarn release
npm pack
npm publish playbook-ui-${{ env.new_npm_alpha_version }}.tgz --tag alpha
gem build playbook_ui.gemspec
echo "${{ env.new_ruby_alpha_version }}"
gem push playbook_ui-${{ env.new_ruby_alpha_version }}.gem --host https://rubygems.org/ --key ${{ env.GEM_HOST_API_KEY }}
- name: Leave PR comment
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RUBY_GEM_VERSION: ${{ env.new_ruby_alpha_version }}
RUBY_GEM_LINK: https://rubygems.org/gems/playbook_ui/versions/${{env.new_ruby_alpha_version}}
NPM_VERSION: ${{ env.new_npm_alpha_version }}
NPM_LINK: https://www.npmjs.com/package/playbook-ui/v/${{env.new_npm_alpha_version}}
run: |
curl -H "Authorization: token ${GITHUB_TOKEN}" \
-X POST \
-d '{"body": "🎉 Congratulations on creating an Alpha Version! \n\n Your Alpha for Ruby Gems is [${{env.RUBY_GEM_VERSION}}](${{env.RUBY_GEM_LINK}}) \n\n Your Alpha for NPM is [${{env.NPM_VERSION}}](${{env.NPM_LINK}}) "}' \
"https://api.github.com/repos/${{ github.repository }}/issues/${PR_NUMBER}/comments"
13 changes: 13 additions & 0 deletions playbook/private/tasks/pb_action.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

namespace :pb_release do
desc "Update the version number in preparation to release"
task :action, [:new_version] do |_task, args|
new_version = args[:new_version]
old_version = Playbook::VERSION
version_rb = File.read("lib/playbook/version.rb")
old_version_rb = version_rb.gsub(/PREVIOUS_VERSION\s=\s"\w{1,3}.\w{1,3}.\w{1,3}"/, "PREVIOUS_VERSION = \"#{old_version}\"")
new_version_rb = old_version_rb.gsub(/\sVERSION\s=\s"\w{1,3}.\w{1,3}.\w{1,3}"/, " VERSION = \"#{new_version}\"")
File.write("lib/playbook/version.rb", new_version_rb)
end
end

0 comments on commit e0fcd86

Please sign in to comment.