Skip to content

Commit

Permalink
Split up release into two steps
Browse files Browse the repository at this point in the history
We now release in two steps:

1. Run script/prepare-release to submit a PR with the version bump
2. Run script/release to tag the current main's HEAD and release it
  • Loading branch information
klappradla committed Apr 19, 2023
1 parent b97a816 commit ed2e2f4
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 1,129 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Download and unpack a `chrome.zip` file from the [releases](https://github.com/b

#### Firefox

Download and unpack a `tickety_tick-<version>.xpi` file from the [releases](https://github.com/bitcrowd/tickety-tick/releases) and open it in Firefox.
Download a `tickety_tick-<version>.xpi` file from the [releases](https://github.com/bitcrowd/tickety-tick/releases) and open it in Firefox.

#### Opera

Expand Down Expand Up @@ -198,6 +198,14 @@ yarn bundle:firefox

### Releasing a new version

Prepare the release by bumping the version and submitting the change as a pull request:

```shell
yarn prepare-release
```

Once the version change is on the `main` branch, you can trigger the release process:

```shell
yarn release
```
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"stylelint": "stylelint --ignore-path .gitignore --syntax scss 'src/**/*.scss'",
"test": "jest",
"checks": "run-s stylelint lint test",
"prepare-release": "./script/prepare-release",
"release": "./script/release"
},
"devDependencies": {
Expand Down Expand Up @@ -65,7 +66,6 @@
"jest-watch-typeahead": "^1.0.0",
"jsdom": "17.0.0",
"mini-css-extract-plugin": "^2.3.0",
"np": "^7.5.0",
"npm-run-all": "4.1.5",
"postcss": "^8.3.8",
"postcss-loader": "6.1.1",
Expand Down
13 changes: 13 additions & 0 deletions script/check-release-dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

set -o errexit
set -o nounset
set -o pipefail

SCRIPTDIR=$(cd "$(dirname "$0")"; pwd)
# shellcheck source=SCRIPTDIR/lib/utils
source "$SCRIPTDIR/lib/utils"

if ! has gh; then
abort "Please install GitHub CLI first (https://cli.github.com)."
fi
12 changes: 12 additions & 0 deletions script/lib/utils
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

# A collection of helpers for our scripts.

function has() {
type "$1" >/dev/null 2>&1
}

function abort() {
printf "${1}\n">&2
exit 1
}
22 changes: 22 additions & 0 deletions script/prepare-release
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

set -o errexit
set -o nounset
set -o pipefail

cd "$(dirname "$0")/.."

./script/check-release-dependencies

branch="chore/prepare-release-$(git rev-parse HEAD)"
git checkout -b "$branch"

yarn version

tag=$(git describe --abbrev=0 --tags)

git tag --delete "$tag"

gh pr create \
--title "Prepare $tag" \
--body "Bump version to $tag."
32 changes: 16 additions & 16 deletions script/release
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@ set -o errexit
set -o nounset
set -o pipefail

SCRIPTDIR=$(cd "$(dirname "$0")"; pwd)
# shellcheck source=SCRIPTDIR/lib/utils
source "$SCRIPTDIR/lib/utils"

cd "$(dirname "$0")/.."

branch="release-$(git rev-parse HEAD)"
git checkout -b "$branch"
./script/check-release-dependencies

branch=$(git branch --show-current)

# Run checks, bump version. Create a commit, tag and push.
yarn np \
--test-script checks \
--branch $branch \
--no-release-draft \
--no-publish
if [[ "$branch" != "main" ]]; then
abort "Please only release from the main branch."
fi

tag=$(git describe --abbrev=0 --tags)
yarn checks

gh pr create \
--title "Release $tag" \
--body ""
version=$(script/version)
tag="v$(version)"

gh pr merge $branch \
--admin \
--rebase
git tag "$(tag)"
git push origin "$tag"

# Build artifacts.
yarn bundle:chrome
Expand All @@ -36,7 +36,7 @@ gh release create "$tag" \
--verify-tag \
./dist/*.zip

if type op >/dev/null 2>&1; then
if has op; then
apikey=$(op item get "bgi26drb3naqhipfmt5wth6634" --field key)
apisecret=$(op item get "bgi26drb3naqhipfmt5wth6634" --field secret)
client_id=$(op item get "yjtvyfa4wcygxlps6smdeybdu4" --field "Client ID")
Expand Down
5 changes: 5 additions & 0 deletions script/version
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env node

const { version } = require("../package.json");

console.log(version);
Loading

0 comments on commit ed2e2f4

Please sign in to comment.