Skip to content

Publish to NPM registry. #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
32 changes: 32 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Release

on:
release: { types: [published] }
workflow_dispatch:

jobs:
npmjs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
registry-url: "https://registry.npmjs.org"
- run: npm publish --ignore-scripts
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

github-npm:
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
registry-url: "https://npm.pkg.github.com"
- name: scope package name as required by GitHub Packages
run: npm init -y --scope ${{ github.repository_owner }}
- run: npm publish --ignore-scripts
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20 changes: 20 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,23 @@ on:
jobs:
test:
uses: bats-core/.github/.github/workflows/test.yml@v1

test-npm-install:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup NodeJs
uses: actions/setup-node@v4
# Move to temp directory, and install package as a user would
- name: Package up project
run: |
npm pack --pack-destination ${{ runner.temp }}
- name: Install using npm
working-directory: ${{ runner.temp }}
env:
BATS_LIB_PATH: ${{ runner.temp }}/node_modules
run: |
npm install ./bats-assert-*.tgz
cp -R ${{github.workspace}}/test/install ./test/
npx bats -r ./test/
9 changes: 3 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Common assertions for Bats",
"homepage": "https://github.com/bats-core/bats-assert",
"license": "CC0-1.0",
"author": "Zoltán Tömböl (https://github.com/ztombol)",
"author": "Bats-core Organization",
"contributors": [
"Sam Stephenson <[email protected]> (http://sstephenson.us/)",
"Jason Karns <[email protected]> (http://jason.karns.name)",
Expand All @@ -23,18 +23,15 @@
],
"scripts": {
"test": "bats ${CI+-t} test",
"test:install": "bats test",
"postversion": "npm publish",
"prepublishOnly": "npm run publish:github",
"publish:github": "git push --follow-tags"
},
"devDependencies": {
"dependencies": {
"bats": "^1",
"bats-support": "^0.3"
},
"peerDependencies": {
"bats": "0.4 || ^1",
"bats-support": "^0.3"
},
"keywords": [
"bats",
"bash",
Expand Down
9 changes: 9 additions & 0 deletions test/install/test_npm_installation.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function setup() {
bats_load_library bats-support
bats_load_library bats-assert
}

@test 'bats-assert is installed and accessible' {
run assert_equal 'batslib_print_kv_single' 'batslib_print_kv_single'
assert_success
}