Skip to content

Commit

Permalink
publish
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasengels committed Oct 10, 2024
1 parent 96d46b5 commit 0f7076d
Show file tree
Hide file tree
Showing 15 changed files with 10,808 additions and 5,475 deletions.
5 changes: 5 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"@typescript-eslint/no-unused-vars": "off" // Disables the rule for unused variables and imports
}
}
93 changes: 93 additions & 0 deletions .github/workflows/build-release-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Build, Test, and Release Angular Library

# Trigger workflow on pull request or push to main
on:
pull_request:
branches:
- main
push:
branches:
- main

jobs:
# Job 1: Test and build library on pull request
test-and-build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

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

- name: Install dependencies
run: npm install

# - name: Run unit tests
# run: npm run test projects/ng-inbo -- --no-watch --no-progress --browsers=ChromeHeadless

- name: Build library
run: npm run build

# Job 2: Publish the library to npm on push to main
publish:
needs: test-and-build
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

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

- name: Install dependencies
run: npm install

- name: Build the library
run: npm run build --prod

- name: Create .npmrc
run: echo "@govflanders:registry=https://registry.npmjs.org//registry.npmjs.org/:_authToke=${{ secrets.NPM_TOKEN }}" > ~/.npmrc

- name: Publish to npm
run: npm run release
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

create-pr:
runs-on: ubuntu-latest
needs: publish # Ensure this job runs after publishing
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
title: "Automated PR for Release"
body: "This PR is created automatically after publishing the library."
base: main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

auto-merge:
runs-on: ubuntu-latest
needs: [create-pr]
if: ${{ github.event.pull_request.merged == false && success() }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Merge PR
uses: devmasx/merge-branch@master
with:
type: now
github_token: ${{ secrets.GITHUB_TOKEN }}
target_branch: 'main'

4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Node.js CI
name: Build

on:
push:
Expand All @@ -16,7 +16,7 @@ jobs:

strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
node-version: [20.x, 22.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Release
on:
push:
branches:
- main

permissions:
contents: write
pull-requests: write

jobs:
release:
name: Release
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 20.x, 22.x ]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: package-lock.json
- run: npm ci
- name: release-please-action
uses: googleapis/release-please-action@v4.1.3
with:
token: ${{ secrets.GITHUB_TOKEN }}
release-type: simple





25 changes: 25 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"release": {
"branches": "main",
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
["@semantic-release/npm", {
"npmPublish": false,
}],
"@semantic-release/github",
["@semantic-release/exec", {
"prepare": "npm run package"
}],
[
"@semantic-release/git",
{
"assets": [
"dist",
"package.json",
"package-lock.json"
],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
]
]
}
4 changes: 3 additions & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"sourceRoot": "projects/ng-inbo/src",
"prefix": "inbo",
"architect": {
"lint": {},
"build": {
"builder": "@angular-devkit/build-angular:ng-packagr",
"options": {
Expand Down Expand Up @@ -36,6 +37,7 @@
}
},
"cli": {
"analytics": false
"analytics": false,
"schematicCollections": ["@angular-eslint/schematics"]
}
}
Loading

0 comments on commit 0f7076d

Please sign in to comment.