Repository navigation
66 lines (66 loc) · 2.1 KB
/
Copy pathrelease.yml
File metadata and controls
66 lines (66 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Publishes the same version to npm and PyPI when a tag like v0.1.1 is pushed. Neither job holds a token:
# both registries trust this workflow of this repository (trusted publishing). A rerun publishes only what is missing.
name: Release
on:
push:
tags: ["v*"]
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 24
- uses: actions/setup-python@v7
with:
python-version: "3.12"
- run: node --test test.mjs
- run: python -m unittest test_cli
- name: The tag is the version of both packages
run: |
version="${GITHUB_REF_NAME#v}"
test "$(node -p 'require("./package.json").version')" = "$version"
grep -q "^version = \"$version\"$" pyproject.toml
npm:
needs: test
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 24
registry-url: https://registry.npmjs.org
- run: npm install -g npm@latest
- name: Publish, unless this version is already there
run: |
version="${GITHUB_REF_NAME#v}"
if npm view "since-dev@$version" version >/dev/null 2>&1; then
echo "::notice::since-dev $version is already on npm"
elif ! npm view since-dev name >/dev/null 2>&1; then
echo "::notice::since-dev is not on npm yet. npm trusts a workflow only for a package that exists, so the first publish is by hand."
else
npm publish --access public
fi
pypi:
needs: test
runs-on: ubuntu-latest
environment: pypi
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: "3.12"
- run: python -m pip install build
- run: python -m build
- uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true