Skip to content

Commit

Permalink
Merge pull request #194 from ably/restructure-scripts
Browse files Browse the repository at this point in the history
Restructure scripts & GH actions
  • Loading branch information
Dominik authored Jun 23, 2022
2 parents f99d8c2 + 32f2adb commit cea0fd6
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 121 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
name: Release Ably UI
name: Release packages

on:
release:
types: [published]

jobs:
run-script:
release:
runs-on: ubuntu-latest
permissions:
packages: write
contents: "read"
pull-requests: "write"
contents: "write"
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -22,10 +21,6 @@ jobs:
with:
node-version: "14.15.4"
- run: npm install -g yarn
- name: Grant permissions to Scripts
run: |
chmod +x "release.sh"
chmod +x "./scripts/update-dependents.sh"
- name: Release latest Ably UI version
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
Expand All @@ -35,9 +30,3 @@ jobs:
git config --global user.name "Github Action"
./scripts/release.sh "${GITHUB_REF/refs\/tags\//}"
shell: bash
- name: Create PR on Voltaire and Website
env:
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
run: "./scripts/update-dependents.sh"
shell: bash
85 changes: 0 additions & 85 deletions .github/workflows/review-app.yml

This file was deleted.

18 changes: 18 additions & 0 deletions .github/workflows/update-dependents.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Update dependents

on:
workflow_run:
workflows: ["Release packages"]
types:
- completed

jobs:
open-prs:
runs-on: ubuntu-latest
steps:
- name: Create PR on Voltaire and Website
env:
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
run: "./scripts/update-dependents.sh"
shell: bash
32 changes: 32 additions & 0 deletions .github/workflows/update-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Update preview

on:
workflow_run:
workflows: ["Release packages"]
types:
- completed

jobs:
update_preview:
needs: release
runs-on: ubuntu-latest
permissions:
contents: "write"
steps:
- uses: actions/checkout@v2
with:
ref: "main"
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.0.0
bundler-cache: true
- uses: actions/setup-node@v2
with:
node-version: "14.15.4"
- run: npm install -g yarn
- name: Update preview app
run: |
git config --global user.email "[email protected]"
git config --global user.name "Github Action"
./scripts/update-preview.sh "${git describe --abbrev=0}"
shell: bash
Empty file modified scripts/build.js
100644 → 100755
Empty file.
23 changes: 2 additions & 21 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ set -euo pipefail
env

VERSION=$1
TAG=v$1

echo "Install packages, making sure they are up to date"
yarn --frozen-lockfile
Expand Down Expand Up @@ -47,27 +46,9 @@ rm ably-ui-$VERSION.gem
echo "Publish the npm package to the registry"
yarn publish --no-git-tag-version --new-version $VERSION

echo "Waiting to make sure packages are available in registries ;("
sleep 180

echo "Update preview app version"
cd preview

echo "Update Gemfile"
sed -i.bak "s/gem 'ably-ui', '.*', require/gem 'ably-ui', '${VERSION}', require/" Gemfile
rm Gemfile.bak

echo "Update ably-ui npm package in preview app"
yarn upgrade @ably/ui@$VERSION

echo "Update Gemfile.lock"
bundle lock # don't change contents gem dir as it might be using local paths

echo "Commit version publish and preview app update to $TAG"
cd ..
echo "Commit version publish"
git add package.json lib/ably_ui/version.rb Gemfile.lock
git add preview/package.json preview/yarn.lock preview/Gemfile preview/Gemfile.lock
git commit -m "Commit version bump & preview app update"
git commit -m "Commit version bump to $VERSION"

echo "Push main to origin"
git push origin main
Empty file modified scripts/setup-modules.js
100644 → 100755
Empty file.
28 changes: 28 additions & 0 deletions scripts/update-preview.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# See https://coderwall.com/p/fkfaqq/safer-bash-scripts-with-set-euxo-pipefail
set -euo pipefail
env

VERSION=$1

echo "Update preview app version"
cd preview

echo "Amend Gemfile to use the right version"
sed -i.bak "s/gem 'ably-ui', '.*', require/gem 'ably-ui', '${VERSION}', require/" Gemfile
rm Gemfile.bak

echo "Upgrade ably-ui npm package in preview app"
yarn upgrade @ably/ui@$VERSION

echo "Upgrade ably-ui ruby gem in preview app"
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"

echo "Push to origin"
git push origin main

0 comments on commit cea0fd6

Please sign in to comment.