-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: streamline package publishing (#453)
* chore(scripts): rename "api:" scripts to "docs" It's not clear whether api:dev or api:docs is the one to run * chore(scripts): add docs generation to version script * chore(scripts): generate docs to /docs for GitHub Pages * chore(docs): move docs to /docs for GitHub Pages * Revert "chore(docs): move docs to /docs for GitHub Pages" This reverts commit 6f3dc53. * Revert "chore(scripts): generate docs to /docs for GitHub Pages" This reverts commit 8750aef. * test(version): avoid hard-coding version in tests It doesn't add much value and makes releases more annoying. * docs(changelog): adjust text * ci: use --check so prettier works * chore(prettier): just check everything * chore(prettier): prettier fixes * ci: create workflow to publish to npm on GitHub release * Suggested changes for CI and release automation Splits the npm scripts into primary development tasks and lifecycle scripts: - `build` - `precommit`: Rebuilds all generated files - `prepack`: Lifecycle script to guarantee compiled files are up-to-date before publishing - `test` - `version`: Lifecycle script to guarantee all files affected by a version bump are regenerated and added to git All other scripts are prefixed with `_` to distinguish between the high-level development tasks above and smaller tasks that can be used as building blocks. Also included in this PR: - extracted the inline script that would check if any generated files had not been committed to `validate-generated-files.sh` * Suggested changes for CI and release automation Splits the npm scripts into primary development tasks and lifecycle scripts: - `build` - `precommit`: Rebuilds all generated files - `prepack`: Lifecycle script to guarantee compiled files are up-to-date before publishing - `test` - `version`: Lifecycle script to guarantee all files affected by a version bump are regenerated and added to git All other scripts are prefixed with `_` to distinguish between the high-level development tasks above and smaller tasks that can be used as building blocks. Also included in this PR: - extracted the inline script that would check if any generated files had not been committed to `validate-generated-files.sh` * Suggested changes for CI and release automation Splits the npm scripts into primary development tasks and lifecycle scripts: - `build` - `precommit`: Rebuilds all generated files - `prepack`: Lifecycle script to guarantee compiled files are up-to-date before publishing - `test` - `version`: Lifecycle script to guarantee all files affected by a version bump are regenerated and added to git All other scripts are prefixed with `_` to distinguish between the high-level development tasks above and smaller tasks that can be used as building blocks. Also included in this PR: - extracted the inline script that would check if any generated files had not been committed to `validate-generated-files.sh` --------- Co-authored-by: Colin Casey <casey.colin@gmail.com>
- Loading branch information
1 parent
9314b09
commit 626f627
Showing
13 changed files
with
129 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,30 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "npm" | ||
directory: "/" | ||
- package-ecosystem: 'npm' | ||
directory: '/' | ||
schedule: | ||
interval: "monthly" | ||
interval: 'monthly' | ||
labels: | ||
- "dependencies" | ||
- "npm" | ||
- "skip changelog" | ||
- 'dependencies' | ||
- 'npm' | ||
- 'skip changelog' | ||
groups: | ||
production-dependencies: | ||
dependency-type: "production" | ||
dependency-type: 'production' | ||
update-types: | ||
- "minor" | ||
- "patch" | ||
- 'minor' | ||
- 'patch' | ||
dev-dependencies: | ||
dependency-type: "development" | ||
dependency-type: 'development' | ||
update-types: | ||
- "minor" | ||
- "patch" | ||
- 'minor' | ||
- 'patch' | ||
ignore: | ||
# We want @types/node to match the *lowest* version of node.js that we support | ||
- dependency-name: "@types/node" | ||
- dependency-name: '@types/node' | ||
update-types: | ||
- "version-update:semver-major" | ||
- "version-update:semver-minor" | ||
- 'version-update:semver-major' | ||
- 'version-update:semver-minor' | ||
# As a library, upgrading TypeScript and using new language features would | ||
# be a breaking change for users who have not yet upgraded their TS version | ||
- dependency-name: "typescript" | ||
- dependency-name: 'typescript' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Publish | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
publish: | ||
name: Publish to NPM | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: lts/* | ||
cache: npm | ||
- name: Install dependencies | ||
run: npm ci | ||
- name: Rebuild generated files | ||
run: npm run prepare-pr | ||
- name: Validated generated API and doc changes have been committed | ||
run: ./validate-generated-files.sh | ||
- name: Publish | ||
run: npm publish --provenance | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
dist | ||
test | ||
api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Changelog | ||
|
||
All notable changes to this project can be found at on the [Releases](https://github.com/salesforce/tough-cookie/releases) | ||
All notable changes to this project can be found on the [GitHub Releases](https://github.com/salesforce/tough-cookie/releases) | ||
page. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
import type { JestConfigWithTsJest } from "ts-jest"; | ||
import type { JestConfigWithTsJest } from 'ts-jest' | ||
|
||
const config: JestConfigWithTsJest = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
rootDir: './lib/', | ||
testPathIgnorePatterns: ['./lib/__tests__/data/'], | ||
fakeTimers: { | ||
enableGlobally: true | ||
} | ||
enableGlobally: true, | ||
}, | ||
} | ||
|
||
export default config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { version } from '../version' | ||
|
||
describe('version file', () => { | ||
it('should have a valid semver version', () => { | ||
expect(typeof version).toBe('string') | ||
expect(version).toMatch(/^\d+?\.\d+?\.\d+?(?:-[\w.]+?)?$/) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env bash | ||
|
||
git add --renormalize . | ||
|
||
if (( "$(git diff HEAD | wc -l)" != 0 )); then | ||
summary=$(cat << EOF | ||
### Detected uncommitted changes from generated files | ||
Use \`npm run precommit\` to ensure that all generated content is up-to-date. | ||
\`\`\`shell | ||
$(git diff HEAD) | ||
\`\`\` | ||
EOF | ||
) | ||
if [ -n "$GITHUB_STEP_SUMMARY" ]; then | ||
echo "$summary" >> "$GITHUB_STEP_SUMMARY" | ||
fi | ||
git --no-pager diff HEAD | ||
exit 1 | ||
fi |