Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: npm-publish

on:
workflow_dispatch:
inputs:
tag:
description: >-
Release tag to publish, for example v1.0.0. Leave empty to run
validation only (dry run).
type: string

permissions:
contents: read

concurrency:
# tag grouping - queues repeat publishes of the same release
# run_id - fallback for validation-only runs, which have no tag
group: npm-publish-${{ inputs.tag || github.run_id }}
cancel-in-progress: false

jobs:
validate:
name: Validate
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
ref: ${{ inputs.tag || github.ref }}
persist-credentials: false

- uses: actions/setup-node@v7
with:
node-version: 26.x

- name: verify release version
if: inputs.tag != ''
run: |
pkg_name=$(jq -r .name package.json)
pkg_version=$(jq -r .version package.json)
if [ "v${pkg_version}" != "$RELEASE_TAG" ]; then
echo "package.json version ($pkg_version) does not match release tag ($RELEASE_TAG)"
exit 1
fi
if npm view "${pkg_name}@${pkg_version}" version >/dev/null 2>&1; then
echo "${pkg_name}@${pkg_version} is already published"
exit 1
fi
env:
RELEASE_TAG: ${{ inputs.tag }}

- name: validate publish package contents
run: |
npm pack --dry-run 2>&1 | tee pack.log
grep -q 'lib/' pack.log
! grep -qE '[[:space:]]test/' pack.log
! grep -qE '[[:space:]]tools/' pack.log

publish:
name: publish
needs: validate
if: inputs.tag != ''
runs-on: ubuntu-latest
environment: Publish
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v7
with:
ref: ${{ inputs.tag }}
persist-credentials: false

- uses: actions/setup-node@v7
with:
node-version: 26.x
registry-url: https://registry.npmjs.org

- name: publish to npm
run: npm publish --provenance
31 changes: 31 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
on:
push:
branches:
- master
name: release-please
permissions:
contents: write
issues: write
pull-requests: write
# Releases created with GITHUB_TOKEN cannot trigger other workflows, so
# npm-publish is dispatched explicitly below. workflow_dispatch is one of the
# few events that always creates a run, even from GITHUB_TOKEN.
actions: write
jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: googleapis/release-please-action@v5
id: release
with:
release-type: node

# releases_created is only true on the run that tagged a release, which is
# the run triggered by merging the release PR.
- name: trigger npm-publish
if: steps.release.outputs.releases_created == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
TAG: ${{ steps.release.outputs.tag_name }}
run: gh workflow run npm-publish.yml --ref "$GITHUB_REF_NAME" -f tag="$TAG"
35 changes: 0 additions & 35 deletions .github/workflows/release.yml

This file was deleted.

13 changes: 0 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ JSCS := $(NODE_BIN)/jscs
MOCHA := $(NODE_BIN)/mocha
NYC := $(NODE_BIN)/nyc
COVERALLS := $(NODE_BIN)/coveralls
UNLEASH := $(NODE_BIN)/unleash
CONVENTIONAL_RECOMMENDED_BUMP := $(NODE_BIN)/conventional-recommended-bump


#
Expand Down Expand Up @@ -118,17 +116,6 @@ clean: ## Cleans unit test coverage files and node_modules.
@rm -rf $(NODE_MODULES) $(COVERAGE) $(COVERAGE_RES) $(YARN_LOCK) $(PACKAGE_LOCK)


.PHONY: release-dry
release-dry: $(NODE_MODULES) $(UNLEASH) ## Dry run of `release` target
@$(UNLEASH) -d --type=$(shell $(CONVENTIONAL_RECOMMENDED_BUMP) -p conventionalcommits)


.PHONY: release
release: $(NODE_MODULES) $(UNLEASH) security ## Versions, tags, and updates changelog based on commit messages
@$(UNLEASH) --type=$(shell $(CONVENTIONAL_RECOMMENDED_BUMP) -p conventionalcommits) --no-publish
@$(NPM) publish


.PHONY: security
security: $(NODE_MODULES) ## Check for dependency vulnerabilities.
@# remove lockfile, reinstall to get latest deps and regen lockfile
Expand Down
19 changes: 6 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -642,21 +642,14 @@ If you have style errors, you can auto fix whitespace issues by running:
make codestyle-fix
```

### Cutting a release
### Releasing

In order to release a new version of the restify-clients module:
Releases are automated with [release-please](https://github.com/googleapis/release-please#readme):

```sh
make release
```

This will run the release target, which will:

1. Automatically update the changelog.
2. Automatically bump the version number appropriate, using the conventional
commit messages found in the git history since the last release.
3. Push the git tags up to origin
4. Call `npm publish`
1. Merge conventional-commit-style PRs (`fix:`, `feat:`, etc.) into `master`.
2. `release-please` opens or updates a Release PR with the version bump and changelog.
3. Review and merge the Release PR when ready to ship.
4. `release-please` tags the release and dispatches the `npm-publish` workflow, which validates and publishes the package to npm.

## License

Expand Down
7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
],
"repository": {
"type": "git",
"url": "https://github.com/restify/clients.git"
"url": "git+https://github.com/restify/clients.git"
},
"license": "MIT",
"engines": {
Expand All @@ -51,8 +51,6 @@
"@commitlint/cli": "^9.0.1",
"@commitlint/config-conventional": "^9.0.1",
"chai": "^4.2.0",
"conventional-changelog-conventionalcommits": "^4.3.0",
"conventional-recommended-bump": "^6.0.9",
"coveralls": "^3.0.2",
"eslint": "^4.19.1",
"jscs": "^3.0.7",
Expand All @@ -62,8 +60,7 @@
"nyc": "^14.1.1",
"proxyquire": "^2.0.1",
"restify": "^12.0.0",
"sinon": "^6.1.3",
"unleash": "^2.0.1"
"sinon": "^6.1.3"
},
"dependencies": {
"assert-plus": "^1.0.0",
Expand Down
Loading