Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🛠️ Automatically publish releases to NPM #6

Merged
merged 47 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
bffa927
:hammer_and_wrench: Automatically create NPM releases
miguelangelmorenochacon Jul 1, 2024
d75daac
Fix regex
miguelangelmorenochacon Jul 1, 2024
55f1298
Fix regex
miguelangelmorenochacon Jul 1, 2024
fe439f9
Add sample tag
miguelangelmorenochacon Jul 1, 2024
23de014
Add sample tag
miguelangelmorenochacon Jul 1, 2024
995d046
Run only on tag push
miguelangelmorenochacon Jul 1, 2024
022963a
Run only on tag push
miguelangelmorenochacon Jul 1, 2024
0a19582
Run only on tag push
miguelangelmorenochacon Jul 1, 2024
42b38c0
Only run on tag push
miguelangelmorenochacon Jul 1, 2024
7ab1673
Add tag validations
miguelangelmorenochacon Jul 1, 2024
ad44b84
Add tag latest option
miguelangelmorenochacon Jul 1, 2024
9729780
Add tag latest option
miguelangelmorenochacon Jul 1, 2024
224dd4f
Install Node
miguelangelmorenochacon Jul 1, 2024
3987aad
Enable corepack
miguelangelmorenochacon Jul 1, 2024
9780c8b
Install CI
miguelangelmorenochacon Jul 1, 2024
94438fd
Add scope
miguelangelmorenochacon Jul 1, 2024
d5b91f6
Add yarn npm publish
miguelangelmorenochacon Jul 1, 2024
241cc36
Set always-auth
miguelangelmorenochacon Jul 1, 2024
13255aa
Add yarn auth
miguelangelmorenochacon Jul 1, 2024
3d77bba
Add yanr publish repo
miguelangelmorenochacon Jul 1, 2024
d9634a1
Add yanr publish repo
miguelangelmorenochacon Jul 1, 2024
7bb5e24
Add debug
miguelangelmorenochacon Jul 1, 2024
aa7bdfd
Change package org
miguelangelmorenochacon Jul 1, 2024
6b3df4c
Revert "Change package org"
miguelangelmorenochacon Jul 1, 2024
06755e8
Add new token
miguelangelmorenochacon Jul 1, 2024
1a6ce08
Add new token
miguelangelmorenochacon Jul 1, 2024
7dbd81b
Change registry
miguelangelmorenochacon Jul 1, 2024
df667e5
Create new version
miguelangelmorenochacon Jul 1, 2024
0017fea
Update tag
miguelangelmorenochacon Jul 1, 2024
a6afd8f
Install yarn
miguelangelmorenochacon Jul 1, 2024
e56e205
Install yarn
miguelangelmorenochacon Jul 1, 2024
15ef2fd
Install yarn
miguelangelmorenochacon Jul 1, 2024
2987ff0
Update package version
miguelangelmorenochacon Jul 1, 2024
934eab9
Update package version
miguelangelmorenochacon Jul 1, 2024
636dd7c
Update package version
miguelangelmorenochacon Jul 1, 2024
0d332e6
Remove fixme
miguelangelmorenochacon Jul 1, 2024
e1d112b
Remove fixme
miguelangelmorenochacon Jul 1, 2024
82b9644
Remove fixme
miguelangelmorenochacon Jul 1, 2024
c86073b
Remove fixme
miguelangelmorenochacon Jul 1, 2024
ede0311
Remove tag preffix
miguelangelmorenochacon Jul 3, 2024
d6150ad
Remove tag preffix
miguelangelmorenochacon Jul 3, 2024
b9ee49b
Remove tag preffix
miguelangelmorenochacon Jul 3, 2024
cc1cb01
Remove tag preffix
miguelangelmorenochacon Jul 3, 2024
3062a1a
Remove tag preffix
miguelangelmorenochacon Jul 3, 2024
3292a94
Change CI order
miguelangelmorenochacon Jul 3, 2024
6cd07c4
Change CI order
miguelangelmorenochacon Jul 3, 2024
9533457
Skip on wrong tag set
miguelangelmorenochacon Jul 15, 2024
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
104 changes: 81 additions & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,105 @@ name: CI
on:
push:
branches: [main]
tags: ['*']

donmccurdy marked this conversation as resolved.
Show resolved Hide resolved
pull_request:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest
name: Build [Node.js ${{ matrix.node-version }}]
runs-on: ubuntu-22.04

strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
include:
- node-version: 18.x
publish: false
- node-version: 20.x
publish: true # Publish on npm
- node-version: 22.x
publish: false

env:
CI: true

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
- 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 }}
- run: corepack enable
- run: yarn install
- run: yarn build
- run: yarn test

lint:
runs-on: ubuntu-latest
- name: Enable Corepack
run: corepack enable

strategy:
matrix:
node-version: [22.x]
- name: Install
run: yarn install

env:
CI: true
- name: Lint
miguelangelmorenochacon marked this conversation as resolved.
Show resolved Hide resolved
run: yarn lint

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
- 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:
node-version: ${{ matrix.node-version }}
- run: corepack enable
- run: yarn install
- run: yarn lint
script: |
const regex = /(alpha|beta)/
const refName = context.ref.replace('refs/tags/', '')
console.log(`Ref tag: ${refName}`)
const releaseTypeMatch = refName.match(regex)
if (!releaseTypeMatch) {
donmccurdy marked this conversation as resolved.
Show resolved Hide resolved
releaseType = 'latest'
} else {
releaseType = releaseTypeMatch[0]
}
miguelangelmorenochacon marked this conversation as resolved.
Show resolved Hide resolved
console.log(`Release type: ${releaseType}`)
return releaseType

# 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 && steps.get-release-type.outputs.result == 'latest'
run: echo "Tag set may be incorrect. Please, review" && exit 1

- name: Configure yarn to publish packages
if: startsWith(github.ref, 'refs/tags/') && matrix.publish
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/') && matrix.publish
env:
RELEASE_TYPE: ${{ steps.get-release-type.outputs.result }}
run: yarn npm publish --tag ${RELEASE_TYPE}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@carto/api-client",
"version": "0.0.1-2",
"version": "0.0.35",
"publishConfig": {
"access": "public",
"tag": "alpha"
Expand Down