This repository has been archived by the owner on May 1, 2023. It is now read-only.
Add ability to manually specify user IDs #32
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish | |
on: | |
push: | |
paths: | |
- "package.json" | |
- ".github/workflows/publish.yml" | |
jobs: | |
validate-version: | |
name: Validate Version | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Get previous tag | |
id: getPreviousTag | |
uses: actions-ecosystem/action-get-latest-tag@v1 | |
- name: Validate Version | |
env: | |
PREVIOUS_VERSION: ${{ steps.getPreviousTag.outputs.tag }} | |
run: | | |
CURRENT_VERSION=$(jq -r .version package.json) | |
PREV_VER_GEQ_CUR_VER=$( | |
jq -r -n --arg previous_version "${PREVIOUS_VERSION}" --arg current_version "${CURRENT_VERSION}" ' | |
def ver2arr($inp): ($inp | split(".") | map(tonumber)); | |
ver2arr($previous_version) as $ver_prev | |
| ver2arr($current_version) as $ver_cur | |
| if ($ver_prev[0] > $ver_cur[0]) or ($ver_prev[1] > $ver_cur[1] and $ver_cur[1] != 0) or ($ver_prev[2] >= $ver_cur[2] and $ver_cur[2] != 0) then true else false end | |
') | |
if [ "${PREV_VER_GEQ_CUR_VER}" = true ]; then | |
echo "Previous version is greater than or equal to current version." | |
echo "Please update package.json with a valid SemVer version greater than ${PREVIOUS_VERSION} before pushing again!" | |
exit 1 | |
fi | |
publish: | |
permissions: | |
contents: write | |
name: Publish to NPM | |
needs: [validate-version] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
registry-url: 'https://registry.npmjs.org' | |
- name: Get previous tag | |
id: getPreviousTag | |
uses: actions-ecosystem/action-get-latest-tag@v1 | |
- name: Get version from package.json | |
id: lookupPackageVersion | |
run: echo "::set-output name=PACKAGE_VERSION::$(jq -r .version package.json)" | |
- name: Bump version and push tag | |
uses: mathieudutour/github-tag-action@v6.1 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
tag_prefix: '' | |
custom_tag: ${{ steps.lookupPackageVersion.outputs.PACKAGE_VERSION }} | |
- name: Generate release diff | |
env: | |
BEGIN_COMMIT: ${{ steps.getPreviousTag.outputs.tag }} | |
END_COMMIT: ${{ steps.lookupPackageVersion.outputs.PACKAGE_VERSION }} | |
run: git fetch --tags --force && git log --pretty=format:"* %s (%h)" ${BEGIN_COMMIT}..${END_COMMIT} > RELEASE_NOTES.md | |
- name: Build package | |
run: | | |
yarn | |
yarn build | |
- name: Create release | |
uses: ncipollo/release-action@v1 | |
with: | |
allowUpdates: true | |
bodyFile: "RELEASE_NOTES.md" | |
draft: false | |
prerelease: false | |
tag: ${{ steps.lookupPackageVersion.outputs.PACKAGE_VERSION }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- run: yarn publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |