Skip to content

Commit ec6b741

Browse files
Merge #1304
1304: Create new publish CI for beta versions r=bidoubiwa a=bidoubiwa To be able to create beta releases on different subjects: `bumps`, `features`, etc.. we needed to provide a better suited CI. This CI also checks if the tag well formated to ensure we do not publish a version that does not follow the naming convention. The workflow has been tested on a private directory and seems to work correctly ⚠️ the `--dry-run` tag on the beta `npm publish . --tag beta --dry-run` is voluntarily added. The idea is to make a try run to ensure that it does what it is suppose to do! Co-authored-by: Charlotte Vermandel <[email protected]>
2 parents 9e19499 + e3e9ba0 commit ec6b741

File tree

3 files changed

+62
-15
lines changed

3 files changed

+62
-15
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/sh
2+
3+
# Checking if current tag matches the required formating
4+
is_pre_release=$1
5+
current_tag=$(echo $GITHUB_REF | cut -d '/' -f 3 | tr -d ' ',v)
6+
7+
if [ $is_pre_release = false ]; then
8+
# Works with the format vX.X.X
9+
#
10+
# Example of correct format:
11+
# v0.1.0
12+
echo "$current_tag" | grep -E "[0-9]*\.[0-9]*\.[0-9]*$"
13+
if [ $? != 0 ]; then
14+
echo "Error: Your tag: $current_tag is wrongly formatted."
15+
echo 'Please refer to the contributing guide for help.'
16+
exit 1
17+
fi
18+
exit 0
19+
elif [ $is_pre_release = true ]; then
20+
# Works with the format vX.X.X-xxx-beta.X
21+
# none or multiple -xxx are valid
22+
#
23+
# Examples of correct format:
24+
# v0.1.0-beta.0
25+
# v0.1.0-xxx-beta.0
26+
# v0.1.0-xxx-xxx-beta.0
27+
echo "$current_tag" | grep -E "[0-9]*\.[0-9]*\.[0-9]*-([a-z]*-)*beta\.[0-9]*$"
28+
29+
if [ $? != 0 ]; then
30+
echo "Error: Your beta tag: $current_tag is wrongly formatted."
31+
echo 'Please refer to the contributing guide for help.'
32+
exit 1
33+
fi
34+
exit 0
35+
fi
36+
37+
exit 0

.github/workflows/publish.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,19 @@ jobs:
1414
registry-url: https://registry.npmjs.org/
1515
- name: Check release validity
1616
run: sh .github/scripts/check-release.sh
17+
- name: Check tag format
18+
run: sh .github/scripts/check-tag-format.sh "${{ github.event.release.prerelease }}"
1719
- name: Install dependencies
1820
run: yarn install
1921
- name: Build meilisearch-js
2022
run: yarn build
2123
- name: Publish with latest tag
22-
if: "!github.event.release.prerelease"
24+
if: "!github.event.release.prerelease && !contains(github.ref, 'beta')"
2325
run: npm publish .
2426
env:
2527
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
2628
- name: Publish with beta tag
27-
if: "github.event.release.prerelease"
28-
run: npm publish . --tag beta
29+
if: "github.event.release.prerelease && contains(github.ref, 'beta')"
30+
run: npm publish . --tag beta --dry-run
2931
env:
3032
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

CONTRIBUTING.md

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -135,16 +135,25 @@ GitHub Actions will be triggered and push the package to [npm](https://www.npmjs
135135

136136
Here are the steps to release a beta version of this package:
137137

138-
- Create a new branch originating the branch containing the "beta" changes. For example, if during the Meilisearch pre-release, create a branch originating `bump-meilisearch-v*.*.*`.<br>
139-
`vX.X.X` is the next version of the package, NOT the version of Meilisearch!
140-
141-
```bash
142-
git checkout bump-meilisearch-v*.*.*
143-
git pull origin bump-meilisearch-v*.*.*
144-
git checkout -b vX.X.X-beta.0
145-
```
146-
147-
- Change the version in `package.json` with `X.X.X-beta.0` and commit it to the `vX.X.X-beta.0` branch
138+
- Create a new branch containing the "beta" changes with the following format `xxx-beta` where `xxx` explains the context.
139+
140+
For example:
141+
- When implementing a beta feature, create a branch `my-feature-beta` where you implement the feature.
142+
```bash
143+
git checkout -b my-feature-beta
144+
```
145+
- During the Meilisearch pre-release, create a branch originating from `bump-meilisearch-v*.*.*` named `meilisearch-v*.*.*-beta`. <br>
146+
`v*.*.*` is the next version of the package, NOT the version of Meilisearch!
147+
148+
```bash
149+
git checkout bump-meilisearch-v*.*.*
150+
git pull origin bump-meilisearch-v*.*.*
151+
git checkout -b bump-meilisearch-v*.*.*-beta
152+
```
153+
154+
- Change the version in `package.json` with `*.*.*-xxx-beta.0` and commit it to the `v*.*.*-beta` branch. None or multiple `-xxx`are valid. Examples:
155+
- `v*.*.*-my-feature-beta.0`
156+
- `v*.*.*-beta.0`
148157

149158
- Go to the [GitHub interface for releasing](https://github.com/meilisearch/meilisearch-js/releases): on this page, click on `Draft a new release`.
150159

@@ -159,8 +168,7 @@ git checkout -b vX.X.X-beta.0
159168
GitHub Actions will be triggered and push the beta version to [npm](https://www.npmjs.com/package/meilisearch).
160169

161170
💡 If you need to release a new beta for the same version (i.e. `vX.X.X-beta.1`):
162-
- merge the change into `bump-meilisearch-v*.*.*`
163-
- rebase the `vX.X.X-beta.0` branch
171+
- merge the change into your beta branch
164172
- change the version name in `package.json`
165173
- creata a pre-release via the GitHub interface
166174

0 commit comments

Comments
 (0)