Skip to content
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

Add GH action to auto publish packages on Tag #216

Merged
merged 8 commits into from
Apr 29, 2022
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
39 changes: 39 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Publish package to NPM

on:
push:
tags:
- '*'

jobs:
tests-ci:
strategy:
fail-fast: false
matrix:
node-version: [ 14, 16 ]
os: [ ubuntu-latest ] #in the future we should add windows here
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
registry-url: https://registry.npmjs.org/
- name: Install Deps
run: npm install
- name: Run tests
run: npm t

build-and-publish:
runs-on: ubuntu-latest
needs: tests-ci
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 14
registry-url: https://registry.npmjs.org/
- run: npm install
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_KEY}}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.vscode/
.idea/
npm-debug.log*
node_modules/
dist/
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"npm": ">=6"
},
"scripts": {
"prepublishOnly": "tsc",
"pretest": "npx tsc",
"test": "mocha --timeout 4s test/init.js 'test/**/*.test.js'",
"tsc:w": "tsc -w",
Expand Down
34 changes: 34 additions & 0 deletions tools/tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

VER_FILE="package.json"

# This script simply sets up the repo for a new tag
echo "Current version number is: "

grep '"version"' $VER_FILE


read -r -p "Please enter a new version number to bump to: " VERSION

echo -e "Updating $VER_FILE to $VERSION\n"

sed -i -e "s/\"version\": .*/\"version\": \"$VERSION\",/" $VER_FILE

read -r -n 1 -p "Would you like to git commit and tag now? (y/N): " YN

# there are better ways to get this in but 🤷
echo ""

case $YN in
y|Y )
echo "Okay, committing this change";
git commit -m "Version bump to $VERSION" -m "This commit was auto generated by a tool!"
git tag -a "v$VERSION" -m "Version bump to $VERSION" -m "This tag was auto generated by a tool!"
git tag --sort -refname | head -n 5
echo "Done!"
;;
* )
echo -e "Okay exiting now. $VER_FILE has still been edited to contain the new version\nFair warning!"
exit 0
;;
esac