Skip to content

Commit a966e00

Browse files
authored
Update how-to guides (#443)
1 parent e1af67d commit a966e00

File tree

4 files changed

+48
-35
lines changed

4 files changed

+48
-35
lines changed

docs/source/how_to_guides/convert_repo_from_releaser.md

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ See checklist below for details:
1717
A. Prep the `jupyter_releaser` fork:
1818

1919
- [ ] Clone this repository onto your GitHub user account.
20-
- [ ] Add a [GitHub Access token](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) with access to target GitHub repo to run GitHub Actions, saved as
21-
`ADMIN_GITHUB_TOKEN` in the [repository secrets](https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository).
20+
- [ ] Add a GitHub [personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) with access to target GitHub repo to run
21+
GitHub Actions, saved as `ADMIN_GITHUB_TOKEN` in the
22+
[repository secrets](https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository).
23+
The token will need "public_repo", and "repo:status" permissions.
2224
- [ ] Add access token for the [PyPI registry](https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/#saving-credentials-on-github) stored as `PYPI_TOKEN`.
2325
_Note_ For security reasons, it is recommended that you scope the access
2426
to a single repository, and use a variable called `PYPI_TOKEN_MAP` that is formatted as follows:
@@ -44,36 +46,42 @@ B. Prep target repository:
4446
- Can use `pandoc -s changelog.rst -o changelog.md` and some hand edits as needed.
4547
- Note that [directives](https://myst-parser.readthedocs.io/en/latest/using/syntax.html#syntax-directives) can still be used
4648
- [ ] Add HTML start and end comment markers to Changelog file - see example in [CHANGELOG.md](https://github.com/jupyter-server/jupyter_releaser/blob/main/CHANGELOG.md) (view in raw mode)
47-
- [ ] Add [tbump](https://github.com/tankerhq/tbump) support if using Python - see example metadata in [pyproject.toml](https://github.com/jupyter-server/jupyter_releaser/blob/main/pyproject.toml)
48-
- We recommend putting `setuptools` metadata in `setup.cfg` and using `version = attr: <package_name>.__version__`.
49-
- See documentation on `setup.cfg` [metadata](https://setuptools.readthedocs.io/en/latest/userguide/declarative_config.html)
50-
- If previously providing `version_info` like `version_info = (1, 7, 0, '.dev', '0')`, use tbump config like the one below:
49+
- [ ] We recommend using [hatch](https://hatch.pypa.io/latest/) for your
50+
build system and for version handling.
51+
- If previously providing `version_info` like `version_info = (1, 7, 0, '.dev', '0')`, use a pattern like the one below in your version file:
5152

5253
```toml
53-
[[tool.tbump.file]]
54-
src = "jupyter_server/_version.py"
55-
version_template = '({major}, {minor}, {patch}, "{channel}", "{release}")'
56-
57-
[[tool.tbump.field]]
58-
name = "channel"
59-
default = ""
60-
61-
[[tool.tbump.field]]
62-
name = "release"
63-
default = ""
54+
import re
55+
from typing import List
56+
57+
# Version string must appear intact for hatch versioning
58+
__version__ = "6.16.0"
59+
60+
# Build up version_info tuple for backwards compatibility
61+
pattern = r"(?P<major>\d+).(?P<minor>\d+).(?P<patch>\d+)(?P<rest>.*)"
62+
match = re.match(pattern, __version__)
63+
assert match is not None
64+
parts: List[object] = [int(match[part]) for part in ["major", "minor", "patch"]]
65+
if match["rest"]:
66+
parts.append(match["rest"])
67+
version_info = tuple(parts)
6468
```
6569

70+
- If you need to keep node and python versions in sync, use [hatch-nodejs-version](https://github.com/agoose77/hatch-nodejs-version). See [nbformat](https://github.com/jupyter/nbformat/blob/main/pyproject.toml) for example.
71+
6672
- [ ] Add a GitHub Actions CI step to run the `check_release` action. For example:
6773

6874
```yaml
6975
- name: Check Release
70-
if: ${{ matrix.python-version == '3.9' }}
71-
uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v1
76+
uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v2
7277
with:
7378
token: ${{ secrets.GITHUB_TOKEN }}
7479
```
7580
76-
_Note_ The check release action needs `contents: write` [permission](https://docs.github.com/en/actions/reference/authentication-in-a-workflow#modifying-the-permissions-for-the-github_token).
81+
- This should be run on `push` and `pull` request events. You can copy
82+
the `check-release.yml` from this repo as an example. ${{ secrets.GITHUB_TOKEN }}
83+
84+
````
7785

7886
- [ ] If you would like the release assets to be uploaded as artifacts, add the following step after the `check_release` action:
7987

@@ -83,12 +91,12 @@ _Note_ The check release action needs `contents: write` [permission](https://doc
8391
with:
8492
name: jupyter-releaser-dist-${{ github.run_number }}
8593
path: .jupyter_releaser_checkout/dist
86-
```
94+
````
8795
8896
- [ ] Add a workflow that uses the [`enforce-label`](https://github.com/jupyterlab/maintainer-tools#enforce-labels) action from `jupyterlab/maintainer-tools` to ensure that all PRs have on of the triage labels used to
8997
categorize the changelog.
9098

91-
- [ ] Update or add `RELEASE.md` that describes the onboarding and release process, e.g.
99+
- [ ] Update or add `RELEASE.md` that describes the onboarding and release process, e.g. [jupyter_server](https://github.com/jupyter-server/jupyter_server/blob/main/RELEASE.md).
92100

93101
## Release Workflow
94102

docs/source/how_to_guides/convert_repo_from_repo.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,18 @@ See [hecklist below for details:
1414

1515
## Checklist for Adoption
1616

17+
- [ ] Add a GitHub [personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token), preferably from a "machine user" GitHub
18+
account that has write access to the repository. The token will need "public_repo", and "repo:status" permissions. Save the token as `ADMIN_GITHUB_TOKEN`
19+
in the [repository secrets](https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository). We need this
20+
access token to allow for branch protection rules, which block the pushing
21+
of commits when using the `GITHUB_TOKEN`, even when run from an admin user
22+
account.
1723
- [ ] Add access token for the [PyPI registry](https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/#saving-credentials-on-github) stored as `PYPI_TOKEN`.
1824
_Note_ For security reasons, it is recommended that you scope the access
1925
to a single repository. Additionally, this token should belong to a
20-
bot account and not a single user.
21-
- [ ] If needed, add access token for [npm](https://docs.npmjs.com/creating-and-viewing-access-tokens), saved as `NPM_TOKEN`.
26+
machine account and not a user account.
27+
- [ ] If needed, add access token for [npm](https://docs.npmjs.com/creating-and-viewing-access-tokens), saved as `NPM_TOKEN`. Again this should
28+
be created using a machine account that only has publish access.
2229
- [ ] Ensure that only trusted users with 2FA have admin access to the
2330
repository, since they will be able to trigger releases.
2431
- [ ] Switch to Markdown Changelog
@@ -47,17 +54,19 @@ if match["rest"]:
4754
version_info = tuple(parts)
4855
```
4956

57+
- If you need to keep node and python versions in sync, use [hatch-nodejs-version](https://github.com/agoose77/hatch-nodejs-version). See [nbformat](https://github.com/jupyter/nbformat/blob/main/pyproject.toml) for example.
58+
5059
- [ ] Add a GitHub Actions CI step to run the `check_release` action. For example:
5160

5261
```yaml
5362
- name: Check Release
54-
if: ${{ matrix.python-version == '3.9' }}
55-
uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v1
63+
uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v2
5664
with:
5765
token: ${{ secrets.GITHUB_TOKEN }}
5866
```
5967
60-
_Note_ The check release action needs `contents: write` [permission](https://docs.github.com/en/actions/reference/authentication-in-a-workflow#modifying-the-permissions-for-the-github_token).
68+
- This should be run on `push` and `pull` request events. You can copy
69+
the `check-release.yml` from this repo as an example.
6170

6271
- [ ] If you would like the release assets to be uploaded as artifacts, add the following step after the `check_release` action:
6372

@@ -72,7 +81,7 @@ _Note_ The check release action needs `contents: write` [permission](https://doc
7281
- [ ] Add a workflow that uses the [`enforce-label`](https://github.com/jupyterlab/maintainer-tools#enforce-labels) action from `jupyterlab/maintainer-tools` to ensure that all PRs have on of the triage labels used to
7382
categorize the changelog.
7483

75-
- [ ] Update or add `RELEASE.md` that describes the onboarding and release process, e.g.
84+
- [ ] Update or add `RELEASE.md` that describes the onboarding and release process, e.g. [jupyter_server](https://github.com/jupyter-server/jupyter_server/blob/main/RELEASE.md).
7685

7786
- [ ] Copy `prep-release.yml` and `publish-release.yml` from the `example-workflows` folder in this repository.
7887

example-workflows/prep-release.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ on:
2121
type: boolean
2222
jobs:
2323
prep_release:
24-
permissions:
25-
contents: write
2624
runs-on: ubuntu-latest
2725
steps:
2826
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
@@ -31,7 +29,7 @@ jobs:
3129
id: prep-release
3230
uses: jupyter-server/jupyter_releaser/.github/actions/prep-release@v2
3331
with:
34-
token: ${{ secrets.GITHUB_TOKEN }}
32+
token: ${{ secrets.ADMIN_GITHUB_TOKEN }}
3533
version_spec: ${{ github.event.inputs.version_spec }}
3634
post_version_spec: ${{ github.event.inputs.post_version_spec }}
3735
target: ${{ github.event.inputs.target }}

example-workflows/publish-release.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,14 @@ on:
1515
jobs:
1616
publish_release:
1717
runs-on: ubuntu-latest
18-
permissions:
19-
contents: write
2018
steps:
2119
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
2220

2321
- name: Populate Release
2422
id: populate-release
2523
uses: jupyter-server/jupyter_releaser/.github/actions/populate-release@v2
2624
with:
27-
token: ${{ secrets.GITHUB_TOKEN }}
25+
token: ${{ secrets.ADMIN_GITHUB_TOKEN }}
2826
target: ${{ github.event.inputs.target }}
2927
branch: ${{ github.event.inputs.branch }}
3028
release_url: ${{ github.event.inputs.release_url }}
@@ -39,7 +37,7 @@ jobs:
3937
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
4038
uses: jupyter-server/jupyter-releaser/.github/actions/finalize-release@v2
4139
with:
42-
token: ${{ secrets.GITHUB_TOKEN }}
40+
token: ${{ secrets.ADMIN_GITHUB_TOKEN }}
4341
target: ${{ github.event.inputs.target }}
4442
release_url: ${{ steps.populate-release.outputs.release_url }}
4543

0 commit comments

Comments
 (0)