Skip to content

Commit f76b1ae

Browse files
committed
Publish to JSR & npm
1 parent 715bcf0 commit f76b1ae

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
lines changed

.github/workflows/main.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,44 @@ jobs:
3737
- run: deno task dnt
3838
- run: bun run ./test_runner.js
3939
working-directory: ${{ github.workspace }}/npm/
40+
41+
publish:
42+
if: github.event_name == 'push'
43+
needs: [test]
44+
runs-on: ubuntu-latest
45+
permissions:
46+
contents: read
47+
id-token: write
48+
steps:
49+
- uses: actions/checkout@v4
50+
- uses: denoland/setup-deno@v1
51+
with:
52+
deno-version: v1.x
53+
- uses: actions/setup-node@v4
54+
with:
55+
node-version: lts/*
56+
- if: github.ref_type == 'branch'
57+
run: |
58+
jq \
59+
--arg build "$GITHUB_RUN_NUMBER" \
60+
--arg commit "${GITHUB_SHA::8}" \
61+
'.version = .version + "-dev." + $build + "+" + $commit' \
62+
deno.json > deno.json.tmp
63+
mv deno.json.tmp deno.json
64+
- if: github.ref_type == 'tag'
65+
run: '[[ "$(jq -r .version deno.json)" = "$GITHUB_REF_NAME" ]]'
66+
- run: 'deno task dnt "$(jq -r .version deno.json)"'
67+
env:
68+
DNT_TEST: false
69+
- run: |
70+
set -ex
71+
npm config set //registry.npmjs.org/:_authToken "$NPM_AUTH_TOKEN"
72+
if [[ "$GITHUB_REF_TYPE" = "tag" ]]; then
73+
npm publish --provenance --access public
74+
else
75+
npm publish --provenance --access public --tag dev
76+
fi
77+
env:
78+
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
79+
working-directory: ${{ github.workspace }}/npm/
80+
- run: deno publish --allow-dirty

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,15 @@
33
@fedify/redis
44
=============
55

6+
[![JSR][JSR badge]][JSR]
7+
[![npm][npm badge]][npm]
8+
[![GitHub Actions][GitHub Actions badge]][GitHub Actions]
9+
610
Redis drivers for Fedify.
11+
12+
[JSR]: https://jsr.io/@fedify/redis
13+
[JSR badge]: https://jsr.io/badges/@fedify/redis
14+
[npm]: https://www.npmjs.com/package/@fedify/redis
15+
[npm badge]: https://img.shields.io/npm/v/@fedify/redis?logo=npm
16+
[GitHub Actions]: https://github.com/dahlia/fedify-redis/actions/workflows/main.yaml
17+
[GitHub Actions badge]: https://github.com/dahlia/fedify-redis/actions/workflows/main.yaml/badge.svg

dnt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ await build({
4444
typeCheck: "both",
4545
declaration: "separate",
4646
declarationMap: true,
47-
test: true,
47+
test: Deno.env.get("DNT_TEST") !== "false",
4848
async postBuild() {
4949
await Deno.copyFile("LICENSE", "npm/LICENSE");
5050
await Deno.copyFile("README.md", "npm/README.md");

0 commit comments

Comments
 (0)