Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Canary versions #403

Merged
merged 61 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
677b12f
Setup repository on publish
igorkamyshev Nov 22, 2023
03f1093
Try to setup beta packages
igorkamyshev Nov 22, 2023
f751a74
Pass GITHUB_TOKEN
igorkamyshev Nov 22, 2023
4287d7a
Migrate
igorkamyshev Nov 22, 2023
fc5c8ef
Replace names for packages
igorkamyshev Nov 22, 2023
ee435f2
Fix invalid nx usage
igorkamyshev Nov 22, 2023
8e21553
Correct replace
igorkamyshev Nov 22, 2023
5c6b429
Setup publishing correctly
igorkamyshev Nov 23, 2023
7dc549e
Revert npmrc setting
igorkamyshev Nov 23, 2023
9bf03be
One more time
igorkamyshev Nov 23, 2023
ed60b6c
Just test change
igorkamyshev Nov 23, 2023
394bb64
One more test
igorkamyshev Nov 23, 2023
a6bb6de
Next step
igorkamyshev Nov 23, 2023
976812d
typo
igorkamyshev Nov 23, 2023
ab1aa80
Pass env
igorkamyshev Nov 23, 2023
ad31441
Pass env
igorkamyshev Nov 23, 2023
7745f17
Filter
igorkamyshev Nov 23, 2023
7d66415
latest beta version
igorkamyshev Nov 23, 2023
075dbd8
logs
igorkamyshev Nov 23, 2023
c6da3cf
logs
igorkamyshev Nov 23, 2023
7ecb6b4
logs
igorkamyshev Nov 23, 2023
7b58ef0
typo
igorkamyshev Nov 23, 2023
d12c2c0
Fix typo
igorkamyshev Nov 23, 2023
161116b
Rewrite versions
igorkamyshev Nov 23, 2023
d2ce43b
fixes
igorkamyshev Nov 23, 2023
4cecb20
Add commenter
igorkamyshev Nov 23, 2023
bd0f86a
Add version to commenter
igorkamyshev Nov 23, 2023
33c9d95
fix typo
igorkamyshev Nov 23, 2023
f2cfd4c
Debug
igorkamyshev Nov 23, 2023
5a858a3
Fix typo
igorkamyshev Nov 23, 2023
0f00e8c
Used to comment
igorkamyshev Nov 23, 2023
74b13e8
Fix typo
igorkamyshev Nov 23, 2023
99d20b8
Fix typo
igorkamyshev Nov 23, 2023
adaf31f
Escape
igorkamyshev Nov 23, 2023
2974e38
Escapes
igorkamyshev Nov 23, 2023
979b689
Next
igorkamyshev Nov 23, 2023
cd33416
Next
igorkamyshev Nov 23, 2023
25ffe85
Next
igorkamyshev Nov 23, 2023
e4f578a
Skip beta
igorkamyshev Nov 23, 2023
d781a9e
Skip beta in comments as well
igorkamyshev Nov 23, 2023
d0d75dd
Expect next version
igorkamyshev Nov 23, 2023
cee0e92
Comments in yaml
igorkamyshev Nov 23, 2023
e91cea3
Use PR number instead of branch name
igorkamyshev Nov 23, 2023
0fbe819
Allow to create new betas
igorkamyshev Nov 23, 2023
e544622
One more tests
igorkamyshev Nov 23, 2023
a45c34d
Use correct overrides for betas"
igorkamyshev Nov 23, 2023
5026931
New beta
igorkamyshev Nov 23, 2023
3ec4083
Add more info about beta
igorkamyshev Nov 23, 2023
a769402
get rid of github npm registry
igorkamyshev Nov 23, 2023
3744d16
get rid of github npm registry 2
igorkamyshev Nov 23, 2023
4db24ab
Do not fail on empty beta versions
igorkamyshev Nov 23, 2023
7dd59e1
Please publish beta
igorkamyshev Nov 23, 2023
24e531c
Fix renaming
igorkamyshev Nov 23, 2023
ae03caa
Naming issues
igorkamyshev Nov 23, 2023
92ac065
Clean up tooling
igorkamyshev Nov 23, 2023
929089e
Improve github comment
igorkamyshev Nov 23, 2023
89d1547
One more beta please
igorkamyshev Nov 23, 2023
e16947b
Improve beta page
igorkamyshev Nov 23, 2023
a109c82
Rename beta versions to canary versions
igorkamyshev Nov 23, 2023
93a2f4c
Rename beta versions to canary versions
igorkamyshev Nov 23, 2023
4032ec8
improve info on site
igorkamyshev Nov 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/big-news-wait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@farfetched/atomic-router': patch
---

New beta
5 changes: 5 additions & 0 deletions .changeset/blue-chefs-own.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@farfetched/atomic-router': patch
---

One more test
5 changes: 5 additions & 0 deletions .changeset/lemon-pots-allow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@farfetched/atomic-router': patch
---

Use correct overrides for betas"
12 changes: 12 additions & 0 deletions .changeset/rare-pets-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
'@farfetched/atomic-router': patch
'@farfetched/core': patch
'@farfetched/io-ts': patch
'@farfetched/runtypes': patch
'@farfetched/solid': patch
'@farfetched/superstruct': patch
'@farfetched/typed-contracts': patch
'@farfetched/zod': patch
---

Just test change
5 changes: 5 additions & 0 deletions .changeset/thick-mice-appear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@farfetched/superstruct': patch
---

One more beta please
5 changes: 5 additions & 0 deletions .changeset/thin-comics-arrive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@farfetched/runtypes': patch
---

Expect next version
5 changes: 5 additions & 0 deletions .changeset/weak-boxes-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@farfetched/atomic-router': patch
---

Please publish beta
5 changes: 5 additions & 0 deletions .changeset/witty-pens-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@farfetched/io-ts': patch
---

One more tests
80 changes: 80 additions & 0 deletions .github/workflows/canary.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Canary

on: pull_request

jobs:
release:
runs-on: ubuntu-latest
steps:
# We store information about used changeset in the comment
# So we need to find it to check if we need to publish a new canary release
# Also we will update this comment with new information in case of new canary release
- name: Find comment about previous canary release
uses: peter-evans/find-comment@v1
id: find_comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Farfetched Canary
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'pnpm'
- name: Authenticate with NPM
run: |
echo "//registry.npmjs.org/:_authToken="${{secrets.NPM_TOKEN}}"" > ~/.npmrc
- run: pnpm install --frozen-lockfile
# Parse latest published version of the canary release and update local package.json for all packages
- name: Restore canary release version
run: node ./tools/scripts/canary/canary_version_restore.mjs ${{ github.event.pull_request.number }}
# Update version in package.json for all packages with changeset and generate pre.json file
- run: pnpm changeset pre enter ${{ github.event.pull_request.number }}
- run: pnpm changeset version
- run: pnpm changeset pre exit
# Check if we need to publish a new canary release
# it uses pre.json file and information about previous canary relase from the comment
- name: Check if new canary release is required
id: canary_required
run: node ./tools/scripts/canary/canary_required.mjs """${{ steps.find_comment.outputs.comment-body }}""" >> $GITHUB_OUTPUT && cat $GITHUB_OUTPUT
- name: Publish canary release
if: steps.canary_required.outputs.skipCanary == ''
run: pnpm nx run-many --output-style=static --target=publish --all --configuration=canary
- name: Retrieve information about latest canary release
id: canary_info
run: node ./tools/scripts/canary/canary_info.mjs >> $GITHUB_OUTPUT && cat $GITHUB_OUTPUT
# In case of absence of the comment we will create it with information about latest canary release
- name: Create comment
if: steps.find_comment.outputs.comment-id == ''
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
# Farfetched Canary

Latest canary version is ${{ steps.canary_info.outputs.canaryVersion }}

[More information about canary versions](https://farfetched.pages.dev/releases/canary.html)

---

Used changeset: ${{ steps.canary_info.outputs.usedChangesets }}
# Otherwise we will update it with information about latest caanry release,
# but only if we published a new canary release
- name: Update comment
if: steps.find_comment.outputs.comment-id != '' && steps.canary_required.outputs.skipCanary == ''
uses: peter-evans/create-or-update-comment@v1
with:
edit-mode: replace
comment-id: ${{ steps.find_comment.outputs.comment-id }}
body: |
# Farfetched Canary

Latest canary version is ${{ steps.canary_info.outputs.canaryVersion }}

[More information about canary versions](https://farfetched.pages.dev/releases/canary.html)

---

Used changeset: ${{ steps.canary_info.outputs.usedChangesets }}
91 changes: 91 additions & 0 deletions apps/website/docs/releases/canary.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
sidebar: false
---

# Canary versions of Farfetched

:::danger
Canary versions are not intended for production use. They can contain bugs and breaking changes, some features can be removed or changed in the stable release.
:::

We release canary versions of Farfetched to allow you to try new features before they are released. Canary versions are published for every PR that contains changesets. You can find the latest canary version of the package for particular PR in the PR comments.

## How to use

1. Replace current versions with the canary versions in `package.json`

```json
{
"dependencies": {
"@farfetched/core": "0.10.4", // [!code --]
"@farfetched/core": "npm:@farfetched-canary/core@0.10.7-403.0" // [!code ++]
}
}
```

2. Install packages

::: code-group

```bash [pnpm]
pnpm install
```

```bash [yarn]
yarn install
```

```bash [npm]
npm install
```

3. Test your application with the canary version of Farfetched

:::

## Deep-dive

In this section, you can find more details about canary versions publishing process.

### Package names

Canary versions of Farfetched are published to scope `@farfetched-canary` instead of `@farfetched`. To use them, you need to change the package name in `package.json` from `@farfetched/*` to `@farfetched-canary/*`.

::: details Full mapping

<script setup>
import { data as mapping } from './canary_mapping.data'
</script>

<table>
<thead>
<tr>
<th>Release package name</th>
<th>Canary package name</th>
</tr>
</thead>
<tbody>
<tr v-for="item in mapping">
<td><code>{{item.release}}</code></td>
<td><code>{{item.canary}}</code></td>
</tr>
</tbody>
</table>

:::

### Package versions

Package versions for canary versions of Farfetched are generated automatically by the following rules:

1. Generate next version of the package according to [semver](https://semver.org/) rules based on changesets in the branch.
2. Add PR number to the end of the version.
3. Add build number to the end of the version.

::: details Examples

- If the latest version of the package is `0.10.4` and branch contains changeset for `minor` change, PR number is `403` and this is the first build for this PR, then the version of the package will be `0.11.0-403.0`.

- If the latest version of the package is `0.10.4` and branch contains changeset for `patch` change, PR number is `406` and this is the second build for this PR, then the version of the package will be `0.10.5-406.1`.

:::
18 changes: 18 additions & 0 deletions apps/website/docs/releases/canary_mapping.data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { createProjectGraphAsync } from '@nrwl/devkit';

process.env.NX_DAEMON = 'false';

export default {
async load() {
const graph = await createProjectGraphAsync();

return Object.values(graph.nodes)
.filter(
(node) => node.type === 'lib' && Boolean(node.data.targets?.build)
)
.map((node) => ({
release: `@farfetched/${node.name}`,
canary: `@farfetched-canary/${node.name}`,
}));
},
};
4 changes: 4 additions & 0 deletions apps/website/docs/releases/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ sidebar: false

Farfetched is mostly been creating in Thailand, so all releases are named after beautiful places in Thailand.

:::tip
To use unreleased version of Farfetched, please refer to [canary](/releases/canary) page.
:::

<script setup>
import { data as releases } from './releases.data'
</script>
Expand Down
9 changes: 7 additions & 2 deletions packages/atomic-router/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,19 @@
"publish": {
"executor": "nx:run-commands",
"options": {
"command": "node tools/scripts/publish.mjs atomic-router"
"command": "node tools/scripts/publish.mjs atomic-router --rename={args.rename}"
},
"dependsOn": [
{
"projects": "self",
"target": "pack"
}
]
],
"configurations": {
"canary": {
"args": "--rename=canary"
}
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
Expand Down
9 changes: 7 additions & 2 deletions packages/core/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,19 @@
"publish": {
"executor": "nx:run-commands",
"options": {
"command": "node tools/scripts/publish.mjs core"
"command": "node tools/scripts/publish.mjs core --rename={args.rename}"
},
"dependsOn": [
{
"projects": "self",
"target": "pack"
}
]
],
"configurations": {
"canary": {
"args": "--rename=canary"
}
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
Expand Down
9 changes: 7 additions & 2 deletions packages/io-ts/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,19 @@
"publish": {
"executor": "nx:run-commands",
"options": {
"command": "node tools/scripts/publish.mjs io-ts"
"command": "node tools/scripts/publish.mjs io-ts --rename={args.rename}"
},
"dependsOn": [
{
"projects": "self",
"target": "pack"
}
]
],
"configurations": {
"canary": {
"args": "--rename=canary"
}
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
Expand Down
9 changes: 7 additions & 2 deletions packages/runtypes/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,19 @@
"publish": {
"executor": "nx:run-commands",
"options": {
"command": "node tools/scripts/publish.mjs runtypes"
"command": "node tools/scripts/publish.mjs runtypes --rename={args.rename}"
},
"dependsOn": [
{
"projects": "self",
"target": "pack"
}
]
],
"configurations": {
"canary": {
"args": "--rename=canary"
}
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
Expand Down
9 changes: 7 additions & 2 deletions packages/solid/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,19 @@
"publish": {
"executor": "nx:run-commands",
"options": {
"command": "node tools/scripts/publish.mjs solid"
"command": "node tools/scripts/publish.mjs solid --rename={args.rename}"
},
"dependsOn": [
{
"projects": "self",
"target": "pack"
}
]
],
"configurations": {
"canary": {
"args": "--rename=canary"
}
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
Expand Down
9 changes: 7 additions & 2 deletions packages/superstruct/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,19 @@
"publish": {
"executor": "nx:run-commands",
"options": {
"command": "node tools/scripts/publish.mjs superstruct"
"command": "node tools/scripts/publish.mjs superstruct --rename={args.rename}"
},
"dependsOn": [
{
"projects": "self",
"target": "pack"
}
]
],
"configurations": {
"canary": {
"args": "--rename=canary"
}
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
Expand Down
Loading