Skip to content

Commit

Permalink
Created workflow for NPM publish
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodrigo Medina committed May 30, 2022
1 parent 89490d1 commit 5cb30b6
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 9 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages

name: Publish NPM package

on:
push:
branches: [master]

jobs:
build:
name: "Build package"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- run: npm ci
- run: npm test

publish-npm:
needs: build
name: "Publish to NPM"
if: "!startsWith(github.ref, 'refs/tags/')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: master
- run: git config --global user.email "[email protected]"
- run: git config --global user.name "Rodrigo Medina"
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm install -g prettier
- run: npm version patch
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

tagged-release:
needs: publish-npm
name: "Tagged Release"
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: "Get Previous tag"
id: previoustag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
automatic_release_tag: "${{ steps.previoustag.outputs.tag }}"
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 9 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hackademymx/challenge-generator",
"version": "0.0.1",
"name": "@roeeyn/challenge-generator",
"version": "2.3.0",
"description": "Fetches a code challenge from the backend, and creates the necessary files to run locally.",
"main": "./lib/index.js",
"bin": {
Expand All @@ -9,15 +9,19 @@
"files": [
"lib/**/*"
],
"publishConfig": {
"access": "public"
},
"scripts": {
"start": "npm run build && npm i -g && challenge-generator",
"test": "jest",
"build": "npm run clean:some && tsc -p .",
"format": "prettier -w .",
"format:check": "prettier -c . '!lib/**/*'",
"prepare": "npm run build",
"prepublishOnly": "npm run format && npm run test",
"preversion": "npm run format",
"version": "npm run format",
"prepublishOnly": "npm run format:check && npm run test",
"preversion": "npm run format:check",
"version": "npm run format:check",
"postversion": "git push && git push --tags",
"global": "npm i -g && challenge-generator",
"clean:some": "rm -rf ./lib ./docs",
Expand Down

0 comments on commit 5cb30b6

Please sign in to comment.