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

chore: add release pipeline #3

Merged
merged 3 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
87 changes: 87 additions & 0 deletions .github/actions/pnpm-install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
########################################################################################
# "pnpm install" composite action for pnpm 7/8+ #
#--------------------------------------------------------------------------------------#
# Requirement: @setup/node should be run before #
# #
# Usage in workflows steps: #
# #
# - name: 📥 Monorepo install #
# uses: ./.github/actions/pnpm-install #
# with: #
# enable-corepack: false # (default) #
# cwd: ${{ github.workspace }}/apps/my-app # (default = '.') #
# #
# Reference: #
# - latest: https://gist.github.com/belgattitude/838b2eba30c324f1f0033a797bab2e31 #
# #
# Versions: #
# - 1.1.0 - 15-07-2023 - Add project custom directory support. #
########################################################################################


name: 'PNPM install'
description: 'Run pnpm install with cache enabled'

inputs:
enable-corepack:
description: 'Enable corepack'
required: false
default: 'false'
cwd:
description: "Changes node's process.cwd() if the project is not located on the root. Default to process.cwd()"
required: false
default: '.'

runs:
using: 'composite'

steps:
- name: ⚙️ Enable Corepack
if: ${{ inputs.enable-corepack == 'true' }}
shell: bash
working-directory: ${{ inputs.cwd }}
run: |
corepack enable
echo "corepack enabled"

- uses: pnpm/action-setup@v2.2.4
if: ${{ inputs.enable-corepack == 'false' }}
with:
run_install: false
# If you're not setting the packageManager field in package.json, add the version here
# version: 8.7.0

- name: Expose pnpm config(s) through "$GITHUB_OUTPUT"
id: pnpm-config
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path | tr -d '\n')" >> $GITHUB_OUTPUT

- name: Cache rotation keys
id: cache-rotation
shell: bash
run: |
echo "YEAR_MONTH=$(/bin/date -u "+%Y%m")" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-config.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-cache-${{ steps.cache-rotation.outputs.YEAR_MONTH }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-cache-${{ steps.cache-rotation.outputs.YEAR_MONTH }}-

# Prevent store to grow over time (not needed with yarn)
# Note: not perfect as it prune too much in monorepos so the idea
# is to use cache-rotation as above. In the future this might work better.
#- name: Prune pnpm store
# shell: bash
# run: pnpm prune store

- name: Install dependencies
shell: bash
working-directory: ${{ inputs.cwd }}
run: pnpm install --frozen-lockfile --prefer-offline
env:
# Other environment variables
HUSKY: '0' # By default do not run HUSKY install
39 changes: 39 additions & 0 deletions .github/workflows/detect-build-issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: 'Detect build issues & coding standards'

on:
pull_request:
branches:
- main
- develop

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:

build-and-test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20

- name: 📥 dependency installation
uses: ./.github/actions/pnpm-install

# Run the linter and verifies the formatting of a set of files. If any errors are found the process exits with a code of 1.
- name: Validate code standards
run: pnpm validate:ci

# Run the build
- name: Generate dependencies
run: pnpm sdk generate

# Run the build
- name: Build the project
run: pnpm sdk prepublish
47 changes: 47 additions & 0 deletions .github/workflows/publish-web-sdk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: 'Release @onbeam/sdk'

on:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
publish-design-system:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: 'main'
fetch-tags: 'true'

- uses: actions/setup-node@v3
with:
node-version: 20
registry-url: 'https://registry.npmjs.org'

- name: 📥 dependency installation
uses: ./.github/actions/pnpm-install

- name: Generate dependencies
run: pnpm sdk generate

- name: Build the sdk
run: pnpm prepublish

- name: Move consumer docs to the sdk package
run: mv ./README.md ./packages/sdk/README.md
run: mv ./LICENSE ./packages/sdk/LICENSE
run: mv ./NOTICE ./packages/sdk/NOTICE

# Set-up the .npmrc to authenticate with the npm registry
- name: Setup npmrc
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc

# Publish packages to npm
- name: 🚀 Publish @onbeam/sdk
run: pnpm publish --no-git-checks --access public
working-directory: ./packages/sdk

2 changes: 2 additions & 0 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
"name": "@onbeam/sdk",
"version": "1.0.0",
"description": "",
"files": ["dist", "./README.md", "./LICENSE", "./NOTICE"],
"main": "dist/index.js",
"types": "dist/index.d.ts",
"private": false,
"scripts": {
"dev": "tsc -w",
"test": "echo \"Error: no test specified\" && exit 1",
Expand Down
Loading