diff --git a/.github/workflows/npm-publish.yaml b/.github/workflows/npm-publish.yaml new file mode 100644 index 0000000..761a93f --- /dev/null +++ b/.github/workflows/npm-publish.yaml @@ -0,0 +1,46 @@ +name: Publish to npm + +on: + workflow_dispatch: + inputs: + tag: + description: 'NPM Tag' + required: false + default: 'next' + +jobs: + tag-and-publish: + runs-on: ubuntu-latest + + steps: + - name: Setup node + uses: actions/setup-node@v1 + with: + node-version: 10 + registry-url: https://registry.npmjs.org + + - name: Git checkout + uses: actions/checkout@v2 + + - name: Install dependencies + run: npm install + env: + CI: true + + - name: Get package version + run: | + export VERSION=`cat package.json | grep version | sed -E 's/.*: "(.*)",/\1/'` + echo "DIST_TAG=v$VERSION" >> $GITHUB_ENV + + - name: Build + run: npm test + + - name: Tag repo with $DIST_TAG + run: | + git tag $DIST_TAG + git push origin $DIST_TAG + + - name: Publish to npm with dist-tag next + run: npm publish --access public --tag ${{ github.event.inputs.tag }} + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/npm-release.yaml b/.github/workflows/npm-release.yaml new file mode 100644 index 0000000..358238f --- /dev/null +++ b/.github/workflows/npm-release.yaml @@ -0,0 +1,34 @@ +name: Release latest on npm + +on: + workflow_dispatch: + inputs: + +jobs: + tag-and-publish: + runs-on: ubuntu-latest + + steps: + - name: Setup node + uses: actions/setup-node@v1 + with: + node-version: 10 + registry-url: https://registry.npmjs.org + + - name: Git checkout + uses: actions/checkout@v2 + + - name: Get package version + run: | + export VERSION=`cat package.json | grep version | sed -E 's/.*: "(.*)",/\1/'` + echo "PKG_VERSION=$VERSION" >> $GITHUB_ENV + + - name: Update dist-tag + run: npm dist-tag add mergely@${PKG_VERSION} latest + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Remove 'next' dist-tag + run: npm dist-tag rm mergely next + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml new file mode 100644 index 0000000..085f5f9 --- /dev/null +++ b/.github/workflows/run-tests.yaml @@ -0,0 +1,41 @@ +name: Run tests + +# on: [push, pull_request] + +on: + push: + branches-ignore: + - 'master' + tags-ignore: + - 'v*' + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [14.x] #, 12.x, 14.x, 15.x + + name: Node.js ${{ matrix.node-version }} + + steps: + - name: Git checkout + uses: actions/checkout@v2 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + - name: Install dependencies + run: npm install + env: + CI: true + + - name: Test + run: npm run test + + - name: Build + run: npm run build:dist