Skip to content

Commit 0bab19e

Browse files
committed
Update package meta/publishing system
1 parent 426d519 commit 0bab19e

File tree

3 files changed

+83
-16
lines changed

3 files changed

+83
-16
lines changed

.github/workflows/release.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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+
with:
33+
version: 9.9.0
34+
35+
- name: Install dependencies
36+
run: pnpm install --no-frozen-lockfile
37+
38+
- name: Run tests
39+
run: pnpm test
40+
41+
- name: Configure git user for CI
42+
run: |
43+
git config user.name "github-actions[bot]"
44+
git config user.email "github-actions[bot]@users.noreply.github.com"
45+
46+
- name: Publish using np with provenance
47+
env:
48+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
49+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
CI: true
51+
run: |
52+
RAW_VERSION='${{ inputs.version }}'
53+
VERSION=$(echo "$RAW_VERSION" | xargs)
54+
if [ -z "$VERSION" ]; then
55+
echo "Error: version input is required" >&2
56+
exit 1
57+
fi
58+
if ! echo "$VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$'; then
59+
echo "Error: provided version '$VERSION' is not valid semver" >&2
60+
exit 1
61+
fi
62+
echo "Publishing exact version: $VERSION"
63+
if git ls-remote --tags origin | grep -q "refs/tags/v$VERSION$"; then
64+
echo "Error: tag v$VERSION already exists on origin. Choose a new version." >&2
65+
exit 1
66+
fi
67+
npm version "$VERSION" -m "release: %s"
68+
git push --follow-tags
69+
npm publish --provenance --access public
70+
71+

README.md

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[action-image]: https://github.com/cezaraugusto/go-git-it/workflows/CI/badge.svg
22
[action-url]: https://github.com/cezaraugusto/go-git-it/actions
3-
[npm-image]: https://img.shields.io/npm/v/go-git-it.svg
3+
[npm-image]: https://img.shields.io/npm/v/go-git-it.svg?color=0971fe
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: 8 additions & 3 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,9 @@
6768
},
6869
"dependencies": {
6970
"progress": "^2.0.3"
70-
}
71+
},
72+
"publishConfig": {
73+
"provenance": true
74+
},
75+
"packageManager": "pnpm@9.9.0+sha512.60c18acd138bff695d339be6ad13f7e936eea6745660d4cc4a776d5247c540d0edee1a563695c183a66eb917ef88f2b4feb1fc25f32a7adcadc7aaf3438e99c1"
7176
}

0 commit comments

Comments
 (0)