CI #51
Workflow file for this run
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: CI | |
on: | |
push: | |
# FIXME: | |
# branches: [main] | |
# branches: [feature/sc-420243/ci-configuration] | |
tags: [v*] | |
# pull_request: | |
# FIMXE: | |
# branches: [main] | |
jobs: | |
build: | |
name: Build [Node.js ${{ matrix.node-version }}] | |
runs-on: ubuntu-22.04 | |
strategy: | |
matrix: | |
# FIXME: | |
# node-version: [18.x, 20.x, 22.x] | |
node-version: [18.x] | |
env: | |
CI: true | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
### | |
# Build | |
### | |
- name: Set up Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Enable Corepack | |
run: corepack enable | |
# - name: Install yarn | |
# run: | | |
# npm install -g yarn | |
# yarn --version | |
- name: Install | |
run: yarn install | |
- name: Build | |
run: yarn build | |
# FIXME: | |
# - name: Lint | |
# run: yarn lint | |
# - name: Test | |
# run: yarn test | |
### | |
# Release | |
### | |
- name: Check tag format | |
id: check-tag-format | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: nowsprinting/check-version-format-action@v4 | |
with: | |
prefix: 'v' | |
- name: Exit on invalid tag format | |
if: startsWith(github.ref, 'refs/tags/') && steps.check-tag-format.outputs.is_valid == 'false' | |
run: echo "Tag must follow SemVer convention. Aborting." && exit 1 | |
- name: Get release type | |
if: startsWith(github.ref, 'refs/tags/') | |
id: get-release-type | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const regex = /(alpha|beta)/ | |
const refName = context.ref.replace('refs/tags/', '') | |
console.log(`Ref tag: ${refName}`) | |
const releaseTypeMatch = refName.match(regex) | |
if (!releaseTypeMatch) { | |
releaseType = 'latest' | |
} else { | |
releaseType = releaseTypeMatch[0] | |
} | |
console.log(`Release type: ${releaseType}`) | |
return releaseType | |
- name: Create the new package version | |
if: startsWith(github.ref, 'refs/tags/') | |
env: | |
RELEASE_TAG: ${{ steps.check-tag-format.outputs.full_without_prefix }} | |
run: | | |
yarn --version | |
yarn version --no-git-tag-version --new-version "${RELEASE_TAG}" | |
- name: Configure yarn to publish packages | |
if: startsWith(github.ref, 'refs/tags/') | |
env: | |
# The following token has been manually issued in the CartoDB | |
# organization for npmjs.com | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_CARTODB_AUTH_TOKEN }} | |
run: | | |
yarn config set npmPublishRegistry "https://registry.npmjs.org/" | |
yarn config set npmAuthToken "${NODE_AUTH_TOKEN}" | |
- name: Publish package | |
if: startsWith(github.ref, 'refs/tags/') | |
env: | |
# The following token has been manually issued in the CartoDB | |
# organization for npmjs.com | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_CARTODB_AUTH_TOKEN }} | |
RELEASE_TYPE: ${{ steps.get-release-type.outputs.result }} | |
run: yarn npm publish --tag ${RELEASE_TYPE} |