Skip to content

Commit 52f1dad

Browse files
committed
Update package meta/publishing system
1 parent 426d519 commit 52f1dad

File tree

3 files changed

+78
-14
lines changed

3 files changed

+78
-14
lines changed

.github/workflows/release.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Publish
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: "Exact version to publish (e.g., 1.1.2). Required."
8+
required: true
9+
type: string
10+
11+
permissions:
12+
contents: write
13+
id-token: write
14+
15+
jobs:
16+
publish:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Setup Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: 20
28+
registry-url: 'https://registry.npmjs.org'
29+
30+
- name: Setup pnpm
31+
uses: pnpm/action-setup@v4
32+
33+
- name: Install dependencies
34+
run: pnpm install --no-frozen-lockfile
35+
36+
- name: Run tests
37+
run: pnpm test
38+
39+
- name: Configure git user for CI
40+
run: |
41+
git config user.name "github-actions[bot]"
42+
git config user.email "github-actions[bot]@users.noreply.github.com"
43+
44+
- name: Publish using np with provenance
45+
env:
46+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
CI: true
49+
run: |
50+
RAW_VERSION='${{ inputs.version }}'
51+
VERSION=$(echo "$RAW_VERSION" | xargs)
52+
if [ -z "$VERSION" ]; then
53+
echo "Error: version input is required" >&2
54+
exit 1
55+
fi
56+
if ! echo "$VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$'; then
57+
echo "Error: provided version '$VERSION' is not valid semver" >&2
58+
exit 1
59+
fi
60+
echo "Publishing exact version: $VERSION"
61+
if git ls-remote --tags origin | grep -q "refs/tags/v$VERSION$"; then
62+
echo "Error: tag v$VERSION already exists on origin. Choose a new version." >&2
63+
exit 1
64+
fi
65+
npm version "$VERSION" -m "release: %s"
66+
git push --follow-tags
67+
npm publish --provenance --access public
68+
69+

README.md

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
[action-url]: https://github.com/cezaraugusto/go-git-it/actions
33
[npm-image]: https://img.shields.io/npm/v/go-git-it.svg
44
[npm-url]: https://npmjs.org/package/go-git-it
5-
[npm-bundle-image]: https://img.shields.io/bundlephobia/min/go-git-it
6-
[npm-bundle-url]: https://npmjs.org/package/go-git-it
75
[npm-downloads-image]: https://img.shields.io/npm/dm/go-git-it
86
[npm-downloads-url]: https://npmjs.org/package/go-git-it
97

10-
# go-git-it [![npm][npm-image]][npm-url] [![downloads][npm-downloads-image]][npm-downloads-url] [![size][npm-bundle-image]][npm-bundle-url] [![workflow][action-image]][action-url]
8+
[![npm][npm-image]][npm-url] [![downloads][npm-downloads-image]][npm-downloads-url] [![workflow][action-image]][action-url]
9+
10+
# go-git-it
1111

1212
> Download any repository or subdirectory on GitHub with support for Node.js and the CLI
1313
@@ -106,15 +106,6 @@ Type: `string`
106106

107107
Adds a custom text message instead of default config. This option overrides the success message as well.
108108

109-
### Features
110-
111-
- Progress bar showing download status
112-
- Support for downloading entire repositories
113-
- Support for downloading specific folders
114-
- Support for downloading individual files
115-
- Custom output directory support
116-
- Custom progress messages
117-
118109
## License
119110

120111
MIT (c) Cezar Augusto.

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@
3333
"dev": "rslib build --watch",
3434
"format": "prettier --write .",
3535
"lint": "eslint .",
36-
"test": "vitest",
37-
"test:coverage": "vitest run --coverage"
36+
"test": "vitest run",
37+
"test:coverage": "vitest run --coverage",
38+
"prepublishOnly": "npm run build"
3839
},
3940
"keywords": [
4041
"git",
@@ -67,5 +68,8 @@
6768
},
6869
"dependencies": {
6970
"progress": "^2.0.3"
71+
},
72+
"publishConfig": {
73+
"provenance": true
7074
}
7175
}

0 commit comments

Comments
 (0)