Skip to content

Commit

Permalink
Merge pull request #1 from AhmedHalat/release-management
Browse files Browse the repository at this point in the history
refactor: swap npm release management
  • Loading branch information
AhmedHalat authored Sep 13, 2024
2 parents 26faa54 + 875e957 commit 926b359
Show file tree
Hide file tree
Showing 9 changed files with 253 additions and 46 deletions.
25 changes: 25 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## PR Summary

Include a summary of the changes and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

**Change**:

- [ ] Feature
- [ ] Bug Fix
- [ ] Refactor
- [ ] Documentation changes
- [ ] Other (provide details):

**Version**:

- [ ] Major (breaking changes that require updates in multiple areas)
- [ ] Minor (new features or enhancements that are backward-compatible)
- [ ] Patch (bug fixes or small updates that do not alter any existing features)

### Control Verification

Include a video or gif of the control in action, if applicable.

### Additional Notes

Add any additional notes or comments that may be helpful for reviewers or stakeholders.
55 changes: 55 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
autolabeler:
- label: "patch"
body:
- '/\[x] Patch/gm'
- label: "minor"
body:
- '/\[x] Minor/gm'
- label: "major"
body:
- '/\[x] Major/gm'
- label: "bugfix"
body:
- '/\[x] Bug Fix/gm'
- label: "documentation"
body:
- '/\[x] Documentation/gm'
- label: "feature"
body:
- '/\[x] Feature/gm'
- label: "enhancement"
body:
- '/\[x] New Component/gm'

version-resolver:
major:
labels:
- "major"
minor:
labels:
- "minor"
patch:
labels:
- "patch"
default: patch

name-template: "v$RESOLVED_VERSION"
tag-template: "$RESOLVED_VERSION"
categories:
- title: "Features"
labels:
- "feature"
- "enhancement"
- title: "Bug Fixes"
labels:
- "fix"
- "bugfix"
- "bug"
- title: "Maintenance"
label: "chore"
change-template: "- $TITLE @$AUTHOR (#$NUMBER)"
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
template: |
## Changes
$CHANGES
66 changes: 66 additions & 0 deletions .github/workflows/npm-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Copyright 2023 (Unpublished) Verto Inc.

name: Create npm registry release

on:
push:
tags:
- "v*.*.*"

jobs:
bump-package-json-release:
runs-on: ubuntu-latest
steps:
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.RELEASE_MANAGER_APP_ID }}
private-key: ${{ secrets.RELEASE_MANAGER_PRIVATE_KEY }}
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ steps.app-token.outputs.token }}
ref: main
- name: Use Node.js 18.x
uses: actions/setup-node@v1
with:
node-version: 18.x
registry-url: "https://npm.pkg.github.com"
env:
NODE_AUTH_TOKEN: ${{ github.token }}

- name: Set tag
id: vars
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT

- name: Update package.json version
run: npm pkg set 'version'="$RELEASE_VERSION"
env:
RELEASE_VERSION: ${{ steps.vars.outputs.tag }}

- name: Setup Git credentials
run: |
git config --global user.name "Astral Release Bot"
git config --global user.email "astral-release@verto.ca"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Commit and push
run: |
git add package.json
git commit -m "Bump version to $RELEASE_VERSION"
git push
git tag -fa "$RELEASE_VERSION" -m "Bump version to $RELEASE_VERSION"
git push origin --tags --force
env:
RELEASE_VERSION: ${{ steps.vars.outputs.tag }}

- name: Run yarn
run: |
yarn
- name: Publish release
run: |
yarn publish
env:
NODE_AUTH_TOKEN: ${{ github.token }}
17 changes: 17 additions & 0 deletions .github/workflows/pr-labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2023 (Unpublished) Verto Inc.

name: Check PR labels

on:
pull_request:
types: [opened, labeled, unlabeled]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: jesusvasquez333/verify-pr-label-action@v1.4.0
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
valid-labels: "major, minor, patch"
invalid-labels: "hold"
24 changes: 24 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Release Drafter

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

permissions:
contents: read

jobs:
update_release_draft:
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17 changes: 16 additions & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"sourceRoot": "projects/astral-accessibility/src",
"prefix": "lib",
"architect": {
"build": {
"e2e": {
"builder": "ngx-build-plus:browser",
"options": {
"outputPath": "dist/astral-accessibility-angular-output",
Expand Down Expand Up @@ -48,6 +48,21 @@
},
"defaultConfiguration": "production"
},
"build": {
"builder": "@angular-devkit/build-angular:ng-packagr",
"options": {
"project": "projects/astral-accessibility/ng-package.json"
},
"configurations": {
"development": {
"tsConfig": "projects/astral-accessibility/tsconfig.app.json"
},
"production": {
"tsConfig": "projects/astral-accessibility/tsconfig.app.json"
}
},
"defaultConfiguration": "development"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
{
"name": "astral-accessibility",
"version": "0.1.0",
"author": "verto-health",
"license": "MIT",
"main": "dist/astral-accessibility",
"scripts": {
"ng": "ng",
"start": "ng serve astral-accessibility",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test",
"cypress": "cypress open",
"build:lib": "ng build --single-bundle --output-hashing=none",
"build:lib": "ng e2e --single-bundle --output-hashing=none",
"build:lib:dev": "ng build --watch --configuration=development --single-bundle",
"start:demo-server": "lite-server -c projects/demo/lite-server-config.json",
"start:demo": "npm-run-all -p build:lib:dev start:demo-server",
"start:test-server": "npm-run-all build:lib start:demo-server"
},
"private": true,
"dependencies": {
"@angular/animations": "^14.1.0",
"@angular/common": "^14.1.0",
Expand Down
45 changes: 2 additions & 43 deletions projects/astral-accessibility/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,3 @@
import { DOCUMENT } from "@angular/common";
import { createCustomElement } from "@angular/elements";
import { createApplication } from "@angular/platform-browser";
import { AstralAccessibilityComponent } from "./lib/astral-accessibility.component";
import "zone.js";
import { initializeAstral } from "./public-api";

(window as any).initializeAstral = async function initializeAstral(
features?: Record<string, any>,
) {
try {
//When no options are given by default all widgets are allowed
if (!features) {
features = {
enabledFeatures: [
"Screen Reader",
"Contrast",
"Saturation",
"Bigger Text",
"Text Spacing",
"Screen Mask",
"Line Height",
],
};
}

const app = await createApplication();
const widget = createCustomElement(AstralAccessibilityComponent, {
injector: app.injector,
});
customElements.define("astral-accessibility", widget);

const doc = app.injector.get(DOCUMENT);
const astralAccessibilityElement = doc.createElement(
"astral-accessibility",
);
astralAccessibilityElement.setAttribute(
"astral-features",
JSON.stringify(features),
);
doc.body.appendChild(astralAccessibilityElement);
} catch (err) {
console.error(err);
}
};
(window as any).initializeAstral = initializeAstral
44 changes: 44 additions & 0 deletions projects/astral-accessibility/src/public-api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { DOCUMENT } from "@angular/common";
import { createCustomElement } from "@angular/elements";
import { createApplication } from "@angular/platform-browser";
import { AstralAccessibilityComponent } from "./lib/astral-accessibility.component";
import "zone.js";

export async function initializeAstral(
features?: Record<string, any>,
) {
try {
//When no options are given by default all widgets are allowed
if (!features) {
features = {
enabledFeatures: [
"Screen Reader",
"Contrast",
"Saturation",
"Bigger Text",
"Text Spacing",
"Screen Mask",
"Line Height",
],
};
}

const app = await createApplication();
const widget = createCustomElement(AstralAccessibilityComponent, {
injector: app.injector,
});
customElements.define("astral-accessibility", widget);

const doc = app.injector.get(DOCUMENT);
const astralAccessibilityElement = doc.createElement(
"astral-accessibility",
);
astralAccessibilityElement.setAttribute(
"astral-features",
JSON.stringify(features),
);
doc.body.appendChild(astralAccessibilityElement);
} catch (err) {
console.error(err);
}
};

0 comments on commit 926b359

Please sign in to comment.