diff --git a/.github/workflows/update-preview.yml b/.github/workflows/update-versions.yml similarity index 63% rename from .github/workflows/update-preview.yml rename to .github/workflows/update-versions.yml index 96e180d46..2723e0bf5 100644 --- a/.github/workflows/update-preview.yml +++ b/.github/workflows/update-versions.yml @@ -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 @@ -27,7 +31,9 @@ jobs: run: | git config --global user.email "github@action.code" 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 }}}} diff --git a/scripts/release.sh b/scripts/release.sh index 86dc8384f..c5df3b31d 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -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" diff --git a/scripts/update-preview.sh b/scripts/update-versions.sh similarity index 55% rename from scripts/update-preview.sh rename to scripts/update-versions.sh index 43f493df0..68eeab680 100755 --- a/scripts/update-preview.sh +++ b/scripts/update-versions.sh @@ -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 @@ -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"