Skip to content

Commit

Permalink
ci: mv npm publish functionality to semantic-release
Browse files Browse the repository at this point in the history
  • Loading branch information
trevor-anderson committed Jun 5, 2024
1 parent da80f53 commit 33f8643
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 42 deletions.
44 changes: 7 additions & 37 deletions .github/workflows/cicd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ on:
permissions:
attestations: write # to generate artifact attestations for dist assets
contents: write # to checkout the code and create a release
id-token: write # to publish to npm using OIDC
id-token: write # to enable use of OIDC for npm provenance
issues: write # to be able to comment on released issues
pull-requests: write # to add coverage reports to a PR
statuses: write # to update commit status

Expand All @@ -31,10 +32,10 @@ jobs:
if: needs.test.outputs.success == 'true'
runs-on: ubuntu-latest
permissions:
contents: write # to create a release
outputs:
new_release_published: ${{ steps.semantic-release.outputs.new_release_published }}
new_release_git_tag: ${{ steps.semantic-release.outputs.new_release_git_tag }}
attestations: write # to generate artifact attestations for dist assets
contents: write # to create a release
id-token: write # to enable use of OIDC for npm provenance
issues: write # to be able to comment on released issues
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -48,36 +49,5 @@ jobs:
@semantic-release/changelog@6.0.3
@semantic-release/git@10.0.1
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN_PUBLISH_PUBLIC_ORG_SCOPE }}
GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}

publish:
name: Publish
needs: release # only publish if a release was created
if: needs.release.outputs.new_release_published == 'true'
runs-on: ubuntu-latest
permissions:
attestations: write # to generate artifact attestations for dist assets
contents: read # to checkout the code
id-token: write # to publish to npm using OIDC
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
registry-url: "https://registry.npmjs.org"
- name: Publish to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_PUBLISH_PUBLIC_ORG_SCOPE }}
run: |
npm ci --include=dev
npm run build
latest_or_next_tag=$(
[[ ${{ needs.release.outputs.new_release_git_tag }} =~ next ]] &&
echo 'next' ||
echo 'latest'
)
npm publish --provenance --access public \
--tag ${{ github.ref }} \
--tag $latest_or_next_tag
5 changes: 0 additions & 5 deletions .npmignore

This file was deleted.

8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
"npm": ">=8.0.0"
},
"type": "module",
"files": [
"dist"
],
"module": "dist/esm/index.js",
"types": "./dist/esm/index.d.ts",
"main": "dist/cjs/index.js",
Expand All @@ -34,6 +37,11 @@
}
},
"private": false,
"publishConfig": {
"access": "public",
"provenance": true,
"registry": "https://registry.npmjs.org/"
},
"repository": {
"type": "git",
"url": "https://github.com/Nerdware-LLC/ts-string-helpers.git"
Expand Down

0 comments on commit 33f8643

Please sign in to comment.