Skip to content

Commit

Permalink
Open PR for versions update in github actions
Browse files Browse the repository at this point in the history
This move the steps that commit a version update into a separate action, which commits to a new branch on opens a PR.

This is because github actions can't push to main directly.
  • Loading branch information
Dominik Piatek committed Aug 5, 2022
1 parent 0f6bdec commit bb9aa3d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: "write"
pull-requests: "write"
steps:
- uses: actions/checkout@v2
with:
ref: "main"
- name: "Get latest tag"
id: latesttag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.0.0
Expand All @@ -27,7 +31,9 @@ jobs:
run: |
git config --global user.email "[email protected]"
git config --global user.name "Github Action"
TAG=$(git describe --abbrev=0)
./scripts/update-preview.sh $TAG
git push https://${{ secrets.REGISTRY_TOKEN }}@github.com/ably/ably-ui.git
./scripts/update-versions.sh ${{ steps.previoustag.outputs.tag }}
shell: bash
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
branch: update-versions-to-${{ ${{ steps.previoustag.outputs.tag }}}}
4 changes: 0 additions & 4 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,3 @@ rm ably-ui-$VERSION.gem

echo "Publish the npm package to the registry"
yarn publish --no-git-tag-version --new-version $VERSION

echo "Commit version publish"
git add package.json lib/ably_ui/version.rb Gemfile.lock
git commit -m "Commit version bump to $VERSION"
14 changes: 13 additions & 1 deletion scripts/update-preview.sh → scripts/update-versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,21 @@ env

VERSION=$1

echo "Update package version"
yarn version --new-version $VERSION --no-git-tag-version

echo "Update version.rb"
# Using -i.bak is a cross-platform way of using sed
# https://stackoverflow.com/a/22084103
sed -i.bak "s/ VERSION = '.*'/ VERSION = '${VERSION}'/" lib/ably_ui/version.rb
rm lib/ably_ui/version.rb.bak

echo "Update preview app version"
cd preview

echo "Amend Gemfile to use the right version"
# Using -i.bak is a cross-platform way of using sed
# https://stackoverflow.com/a/22084103
sed -i.bak "s/gem 'ably-ui', '.*', require/gem 'ably-ui', '${VERSION}', require/" Gemfile
rm Gemfile.bak

Expand All @@ -22,4 +33,5 @@ bundle lock # don't change contents gem dir as it might be using local paths
echo "Commit preview app update to $VERSION"
cd ..
git add preview/package.json preview/yarn.lock preview/Gemfile preview/Gemfile.lock
git commit -m "Update preview app to ably-ui $VERSION"
git add lib/ably_ui/version.rb Gemfile.lock package.json
git commit -m "Update package version & preview app to ably-ui $VERSION"

0 comments on commit bb9aa3d

Please sign in to comment.