-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3527556
commit 406a9d3
Showing
3 changed files
with
126 additions
and
150 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,126 +1,55 @@ | ||
name: Publish CI | ||
name: CI | ||
|
||
on: | ||
push: | ||
tags: ["*"] | ||
|
||
jobs: | ||
build: | ||
name: Build [Node.js ${{ matrix.node-version }}] | ||
name: Build [${{ matrix.framework }} - Node ${{ matrix.node-version }}] | ||
runs-on: ubuntu-22.04 | ||
|
||
strategy: | ||
matrix: | ||
include: | ||
- node-version: 18.x | ||
publish: false | ||
- node-version: 20.x | ||
publish: true # TODO | ||
- node-version: 22.x | ||
publish: false | ||
node-version: [20.x] | ||
framework: [react, vue, angular] | ||
|
||
env: | ||
CI: true | ||
PROJECT_PATH: projects/node-${{ matrix.node-version }}/${{ matrix.framework }} | ||
|
||
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 | ||
run: yarn install | ||
|
||
- name: Lint | ||
run: yarn lint | ||
run: | | ||
corepack enable | ||
yarn install | ||
- name: Build | ||
run: yarn build | ||
|
||
- name: Test | ||
run: yarn test | ||
|
||
########################################################################## | ||
# Publish | ||
########################################################################## | ||
|
||
- name: Check tag format | ||
id: check-tag-format | ||
if: startsWith(github.ref, 'refs/tags/') && matrix.publish | ||
uses: nowsprinting/check-version-format-action@v4 | ||
|
||
- name: Exit on invalid tag format | ||
if: startsWith(github.ref, 'refs/tags/') && !steps.check-tag-format.outputs.is_valid && matrix.publish | ||
run: echo "Tag must follow SemVer convention. Aborting." && exit 1 | ||
|
||
- name: Get release type | ||
if: startsWith(github.ref, 'refs/tags/') && matrix.publish | ||
id: get-release-type | ||
uses: actions/github-script@v7 | ||
with: | ||
result-encoding: string | ||
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: Set version from tag to environment variable | ||
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | ||
|
||
# TODO: Enable after reaching 1.0.0. | ||
# This may indicate that the tag set has a typo, e.g., alpah, betta, etc. | ||
# - name: Verify tag format | ||
# if: steps.check-tag-format.outputs.is_stable == 'false' && steps.get-release-type.outputs.result == 'latest' | ||
# run: echo "Tag set may be incorrect. Please, review" && exit 1 | ||
|
||
# - name: Reset changes | ||
# if: startsWith(github.ref, 'refs/tags/') && matrix.publish | ||
# run: git reset --hard HEAD | ||
|
||
- name: Ignore changes to .yarnrc.yml | ||
if: startsWith(github.ref, 'refs/tags/') && matrix.publish | ||
run: git update-index --assume-unchanged .yarnrc.yml | ||
run: | | ||
yarn lint | ||
yarn build | ||
- name: Configure yarn to publish packages | ||
if: startsWith(github.ref, 'refs/tags/') && matrix.publish | ||
- name: Create project with framework ${{ matrix.framework }} Node-${{ matrix.node-version }} | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_CARTODB_AUTH_TOKEN }} | ||
CARTO_AUTH_TOKEN: ${{ secrets.CARTO_AUTH_TOKEN }} | ||
run: | | ||
# Yarn config | ||
yarn config set npmPublishRegistry "https://registry.npmjs.org/" | ||
yarn config set npmAuthToken "${NODE_AUTH_TOKEN}" | ||
# Create .npmrc file | ||
echo "@carto:registry=https://registry.npmjs.org/" > .npmrc | ||
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" >> .npmrc | ||
# Check configuration | ||
npm config get registry | ||
npm view @carto/create-common versions | ||
mkdir -p ${PROJECT_PATH} | ||
node scripts/generate-ci-project.js ${{ matrix.framework }} ${PROJECT_PATH} ${CARTO_AUTH_TOKEN} | ||
- name: Publish package with Lerna | ||
if: startsWith(github.ref, 'refs/tags/') && matrix.publish | ||
- name: Start project | ||
env: | ||
RELEASE_TYPE: ${{ steps.get-release-type.outputs.result }} | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_CARTODB_AUTH_TOKEN }} | ||
YARN_ENABLE_IMMUTABLE_INSTALLS: false | ||
run: | | ||
set -x | ||
yarn lerna publish from-git --yes --dist-tag ${RELEASE_TYPE} --loglevel verbose | ||
cd ${PROJECT_PATH} | ||
yarn | ||
yarn dev --port 4000 & | ||
sleep 30 | ||
curl http://localhost:4000/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: ['*'] | ||
|
||
jobs: | ||
release: | ||
name: Release [Node.js ${{ matrix.node-version }}] | ||
runs-on: ubuntu-22.04 | ||
|
||
strategy: | ||
matrix: | ||
node-version: [20.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: Install | ||
run: | | ||
corepack enable | ||
yarn install | ||
- name: Lint | ||
run: yarn lint | ||
|
||
- name: Build | ||
run: yarn build | ||
|
||
- name: Test | ||
run: yarn test | ||
|
||
########################################################################## | ||
# Publish | ||
########################################################################## | ||
|
||
- name: Check tag format | ||
id: check-tag-format | ||
uses: nowsprinting/check-version-format-action@v4 | ||
|
||
- name: Exit on invalid tag format | ||
if: '!steps.check-tag-format.outputs.is_valid' | ||
run: echo "Tag must follow SemVer convention. Aborting." && exit 1 | ||
|
||
- name: Get release type | ||
id: get-release-type | ||
uses: actions/github-script@v7 | ||
with: | ||
result-encoding: string | ||
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: Set version from tag to environment variable | ||
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | ||
|
||
- name: Ignore changes to .yarnrc.yml | ||
run: git update-index --assume-unchanged .yarnrc.yml | ||
|
||
- name: Configure yarn to publish packages | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_CARTODB_AUTH_TOKEN }} | ||
run: | | ||
# Yarn config | ||
yarn config set npmPublishRegistry "https://registry.npmjs.org/" | ||
yarn config set npmAuthToken "${NODE_AUTH_TOKEN}" | ||
# Create .npmrc file | ||
echo "@carto:registry=https://registry.npmjs.org/" > .npmrc | ||
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" >> .npmrc | ||
# Check configuration | ||
npm config get registry | ||
npm view @carto/create-common versions | ||
- name: Publish package with Lerna | ||
env: | ||
RELEASE_TYPE: ${{ steps.get-release-type.outputs.result }} | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_CARTODB_AUTH_TOKEN }} | ||
run: | | ||
set -x | ||
yarn lerna publish from-git --yes --dist-tag ${RELEASE_TYPE} --loglevel verbose |
This file was deleted.
Oops, something went wrong.