diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 0000000..40263f0 --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -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 "rodrigo.medina.neri@gmail.com" + - 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 }}" diff --git a/package-lock.json b/package-lock.json index 8905d47..38b88c7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { - "name": "@hackademymx/challenge-generator", - "version": "0.0.1", + "name": "@roeeyn/challenge-generator", + "version": "2.3.0", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "@hackademymx/challenge-generator", - "version": "0.0.1", + "name": "@roeeyn/challenge-generator", + "version": "2.3.0", "license": "MIT", "dependencies": { "commander": "^9.2.0", diff --git a/package.json b/package.json index 466c72a..db993bc 100644 --- a/package.json +++ b/package.json @@ -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": { @@ -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",