Skip to content
Draft
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
43 changes: 19 additions & 24 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: 'Publish package'

# Publishes the version that package.json holds. Only a commit changes that
# version, so a run cannot move it.

permissions:
contents: write

Expand All @@ -11,41 +14,33 @@ env:

on:
workflow_dispatch:
inputs:
version:
description: 'Enter version'
default: '2.0.0'
required: false
type: string

jobs:
publish-package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Create Git Identity
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
- name: Clean cache
run: yarn cache clean --force
- uses: actions/setup-node@v2
- uses: actions/checkout@v4
# The runner's own Node.js, the same one the tests run on.
- uses: actions/setup-node@v4
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: yarn install
- name: Run build
run: yarn run build
- name: Run tests
run: yarn run test
- name: Bump version
run: yarn version --new-version ${{ inputs.version }} && git push
- name: Create git tag
run: |
git tag -af v${{ inputs.version }} -m "Version ${{ inputs.version }}"
git push --tags --force
- name: Publish to NPM
run: yarn publish --access public --tag latest
- name: Publish to npm
run: yarn publish --access public --tag latest --non-interactive
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# The organization's npm token, which the other 51Degrees npm
# packages publish with.
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
# Tagged only once the version is on npm.
- name: Tag the published version
run: |
version=$(node -p "require('./package.json').version")
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
git tag -a "v$version" -m "Version $version"
git push origin "v$version"
Loading