Skip to content

Commit

Permalink
Publish to JSR & npm
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlia committed Jun 20, 2024
1 parent 715bcf0 commit f76b1ae
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
41 changes: 41 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,44 @@ jobs:
- run: deno task dnt
- run: bun run ./test_runner.js
working-directory: ${{ github.workspace }}/npm/

publish:
if: github.event_name == 'push'
needs: [test]
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- uses: actions/setup-node@v4
with:
node-version: lts/*
- if: github.ref_type == 'branch'
run: |
jq \
--arg build "$GITHUB_RUN_NUMBER" \
--arg commit "${GITHUB_SHA::8}" \
'.version = .version + "-dev." + $build + "+" + $commit' \
deno.json > deno.json.tmp
mv deno.json.tmp deno.json
- if: github.ref_type == 'tag'
run: '[[ "$(jq -r .version deno.json)" = "$GITHUB_REF_NAME" ]]'
- run: 'deno task dnt "$(jq -r .version deno.json)"'
env:
DNT_TEST: false
- run: |
set -ex
npm config set //registry.npmjs.org/:_authToken "$NPM_AUTH_TOKEN"
if [[ "$GITHUB_REF_TYPE" = "tag" ]]; then
npm publish --provenance --access public
else
npm publish --provenance --access public --tag dev
fi
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
working-directory: ${{ github.workspace }}/npm/
- run: deno publish --allow-dirty
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,15 @@
@fedify/redis
=============

[![JSR][JSR badge]][JSR]
[![npm][npm badge]][npm]
[![GitHub Actions][GitHub Actions badge]][GitHub Actions]

Redis drivers for Fedify.

[JSR]: https://jsr.io/@fedify/redis
[JSR badge]: https://jsr.io/badges/@fedify/redis
[npm]: https://www.npmjs.com/package/@fedify/redis
[npm badge]: https://img.shields.io/npm/v/@fedify/redis?logo=npm
[GitHub Actions]: https://github.com/dahlia/fedify-redis/actions/workflows/main.yaml
[GitHub Actions badge]: https://github.com/dahlia/fedify-redis/actions/workflows/main.yaml/badge.svg
2 changes: 1 addition & 1 deletion dnt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ await build({
typeCheck: "both",
declaration: "separate",
declarationMap: true,
test: true,
test: Deno.env.get("DNT_TEST") !== "false",
async postBuild() {
await Deno.copyFile("LICENSE", "npm/LICENSE");
await Deno.copyFile("README.md", "npm/README.md");
Expand Down

0 comments on commit f76b1ae

Please sign in to comment.