Skip to content

Release

Release #19

Workflow file for this run

name: Release
on: [workflow_call, workflow_dispatch]
env:
NODE_VERSION: 20
CI: true
jobs:
release:
name: Release
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 10
fetch-tags: true
# References:
# - https://stackoverflow.com/a/65616499
# - https://stackoverflow.com/a/33733020
- name: Read git tag
id: git-tag
run: |
echo "TAG_NAME=$(git tag --points-at HEAD)" >> $GITHUB_OUTPUT
echo "TAG_NAME2=$(git describe)" >> $GITHUB_OUTPUT
echo "TEST=TESTTESTTEST" >> $GITHUB_OUTPUT
# TODO: TESTING v2
- name: Test git tag
env:
GIT_TAG: ${{ steps.git-tag.outputs.TAG_NAME }}
GIT_TAG2: ${{ steps.git-tag.outputs.TAG_NAME2 }}
TEST: ${{ steps.git-tag.outputs.TEST }}
REF_NAME: ${{ github.ref_name }}
REF: ${{ github.ref }}
MESSAGE: ${{ github.event.head_commit.message }}
MESSAGE_RUN: ${{ github.event.workflow_run.head_commit.message }}
MESSAGE_DISPATCH: ${{ github.event.workflow_dispatch.head_commit.message }}
if: contains(env.GIT_TAG, 'v') == false
run: echo "Missing GIT_TAG; aborting" && exit 1
- name: Set up Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Assign dist tag
id: dist-tag
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const gitTag = '${{ steps.git-tag.outputs.TAG_NAME }}'
console.log(`git tag: ${gitTag}`)
if (gitTag.match(/^v\d+\.\d+\.\d+$/)) {
distTag = 'latest'
} else if (gitTag.match(/^v\d+\.\d+\.\d+/)) {
distTag = 'alpha'
} else {
core.setFailed('Tag must follow SemVer convention. Aborting.');
}
console.log(`npm dist tag: ${distTag}`)
return distTag
- name: Install
run: |
corepack enable
yarn install
- name: Build
run: |
yarn lint
yarn build
yarn test
- name: Configure yarn to publish packages
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_CARTODB_AUTH_TOKEN }}
run: |
yarn config set npmPublishRegistry "https://registry.npmjs.org/"
yarn config set npmAuthToken "${NPM_AUTH_TOKEN}"
- name: Publish
env:
DIST_TAG: ${{ steps.dist-tag.outputs.result }}
run: yarn npm publish --tag ${DIST_TAG}