diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index d204696..da0b269 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,8 +1,9 @@ name: Publish +run-name: Publish ${{ github.ref_name }} on: release: - types: [published] + types: [ published ] jobs: publish: @@ -13,18 +14,27 @@ jobs: with: node-version: latest registry-url: https://registry.npmjs.org/ + - name: Install dependencies run: npm ci + + - name: Run tests + run: npm test + - name: Build run: npm run build + - name: Publish to npmjs - run: npm publish --tag latest --access public env: - NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + run: npm publish --tag ${{ contains(github.ref_name, '-') && 'pre' || 'latest' }} --access public + - uses: actions/setup-node@v3 with: + node-version: latest registry-url: https://npm.pkg.github.com/ + - name: Publish to GPR - run: npm publish --tag latest --access public env: - NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: npm publish --tag ${{ contains(github.ref_name, '-') && 'pre' || 'latest' }} --access public \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..66cfefc --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,31 @@ +name: Release +run-name: Release ${{ github.ref_name }} + +on: + push: + tags: + - 'v*' + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: latest + registry-url: https://registry.npmjs.org/ + + - name: Install dependencies + run: npm ci + + - name: Run tests + run: npm test + + - name: Build + run: npm run build + + - name: Create release + run: gh release create ${{ github.ref_name }} --draft ${{ contains(github.ref_name, '-') && '--prerelease --latest=false' || '--latest' }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b21c596..2613873 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,12 @@ jobs: with: node-version: latest registry-url: https://registry.npmjs.org/ + - name: Install dependencies run: npm ci + - name: Run tests - run: npm test \ No newline at end of file + run: npm test + + - name: Build + run: npm run build \ No newline at end of file