Skip to content

Commit

Permalink
ci(cicd): ✨ github actions to build and publish package
Browse files Browse the repository at this point in the history
github actions to build and publish package

Signed-off-by: Tiago Barbosa <tbarbos@hotmail.com>
  • Loading branch information
t1agob committed Dec 5, 2023
1 parent fc5341f commit ae9637c
Show file tree
Hide file tree
Showing 5 changed files with 167 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
change-template: "* $TITLE (#$NUMBER) by @$AUTHOR"
categories:
- title: '⚡ Breaking Changes'
labels:
- 'type/breaking-change'
- title: '🌟New features and non-breaking changes'
labels:
- 'type/feature'
- title: '🌟 Minor Changes'
labels:
- 'type/enhancement'
- title: '📜 Documentation updates'
labels:
- 'area/documentation'
- title: '🐛 Bug and hot fixes'
labels:
- 'type/bug'
- 'type/fix'
- title: '🚒 Deprecations'
labels:
- 'type/deprecation'
- title: '🔧 Maintenance'
labels:
- 'type/internal'
- 'type/dependencies'
exclude-labels:
- 'skip-changelog'
tag-template: 'v$NEXT_PATCH_VERSION'
template: |
## Summary
**[Human readable summary of changes]**
## Changes
$CHANGES
## This release was made possible by the following contributors:
$CONTRIBUTORS
29 changes: 29 additions & 0 deletions .github/workflows/on_push_to_main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Release Drafter

on:
push:
# branches to consider in the event; optional, defaults to all
branches:
- main

permissions:
contents: read

jobs:
update_release_draft:
permissions:
# write permission is required to create a github release
contents: write
# write permission is required for autolabeler
# otherwise, read permission is required at least
pull-requests: write
runs-on: ubuntu-latest
steps:
# Drafts your next Release notes as Pull Requests are merged into "master"
- uses: release-drafter/release-drafter@v5
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
with:
config-name: release-drafter.yml
# disable-autolabeler: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53 changes: 53 additions & 0 deletions .github/workflows/on_release_created.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Release

on:
workflow_dispatch:
inputs:
pre-release:
description: 'Is this a pre-release version?'
required: true
default: true
type: boolean
version:
description: 'Version'
required: true
type: string

jobs:
# publish to npm with the tag "beta" if the release version contains "beta" otherwise publish with the tag "latest"
publish_to_npm:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Node 18
uses: actions/setup-node@v3
with:
node-version: 18
registry-url: "https://registry.npmjs.org"
- name: Install yarn
run: corepack enable
- name: Set yarn version to latest stable
run: corepack prepare yarn@stable --activate
- name: Install dependencies
run: yarn install
- name: lint
run: yarn lint
- name: Build
run: yarn build
- name: Replace NPM Token in yarnrc.yml
uses: datamonsters/replace-action@v2
with:
files: ./.yarnrc.yml
replacements: NPM_TOKEN=${{secrets.npm_token}}
- name: Replace release version in package.json before release
uses: datamonsters/replace-action@v2
with:
files: ./package.json
replacements: NPM_PACKAGE_VERSION=${{ inputs.version }}
- name: Publish beta version to NPM (uses package.json version)
if: ${{ inputs.pre-release }}
run: yarn npm publish --tag next --access public
- name: Publish latest version to NPM (uses package.json version)
if: ${{ !inputs.pre-release }}
run: yarn npm publish --tag latest --access public
38 changes: 38 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages

name: On Pull Request

on:
pull_request:
types: [opened, synchronize, reopened]
branches:
- main
- next

jobs:
ci:
if: github.event.pull_request.state != 'closed'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Node 18
uses: actions/setup-node@v3
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'
- name: Install yarn
run: corepack enable
- name: Set yarn version to latest stable
run: corepack prepare yarn@stable --activate
- name: Install dependencies
run: yarn install
- name: Lint
run: yarn lint
- name: Build
run: yarn build
- name: Test
run: yarn test


7 changes: 7 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
nodeLinker: node-modules

npmRegistryServer: https://registry.npmjs.org/

npmScopes:
pagerduty:
npmAlwaysAuth: true
npmAuthToken: NPM_TOKEN

0 comments on commit ae9637c

Please sign in to comment.