Skip to content

Commit

Permalink
Merge pull request #11 from ctinnovation/feat/npmjs-registry
Browse files Browse the repository at this point in the history
Feat/npmjs registry
  • Loading branch information
giovanni-bertoncelli authored Feb 22, 2024
2 parents 39cead2 + 2f3e71c commit de191bf
Show file tree
Hide file tree
Showing 45 changed files with 7,658 additions and 2,569 deletions.
6 changes: 6 additions & 0 deletions .changescriberc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"generate": {
"fromPackageJson": true,
"excludeTaskList": true
}
}
41 changes: 24 additions & 17 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
module.exports = {
"env": {
"browser": true,
"es6": true
},
"extends": [
"airbnb-base"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"rules": {
env: {
browser: false,
commonjs: true,
es2021: true
},
extends: 'standard',
overrides: [
{
env: {
node: true
},
files: [
'.eslintrc.{js,cjs}'
],
parserOptions: {
sourceType: 'script'
}
}
};
],
parserOptions: {
ecmaVersion: 'latest'
},
rules: {
}
}
19 changes: 0 additions & 19 deletions .github/workflows/npm.yml

This file was deleted.

128 changes: 128 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: Create new release

on:
pull_request:
branches:
- main
types: [closed]
workflow_dispatch:
inputs:
semver:
description: "Semver version"
required: true
default: "minor"

jobs:
create:
name: Create PR for new release
if: github.event.inputs.semver
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.REPO_ACCESS }}

- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: "20.x"

- name: install dependencies
run: npm install -g changescribe
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_GET_TOKEN}}

- name: setup git config
run: |
# setup the username and email. I tend to use 'GitHub Actions Bot' with no email by default
git config user.name "GitHub Actions Bot"
git config user.email "<github@ctinnovation.it>"
- name: update version and changelog
run: |
npm version ${{ github.event.inputs.semver }} --no-git-tag-version
- name: Get new version from package.json
run: |
pkg_version=$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]')
echo "PACKAGE_VERSION=$pkg_version" >> $GITHUB_ENV
echo $PACKAGE_VERSION
- name: Create pull request
id: pr-create
uses: actions/github-script@v6
with:
github-token: ${{ github.token }}
script: |
const res = await github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/tagname",
head: "release_${{ env.PACKAGE_VERSION }}",
base: "main",
title: "Release: [v${{ env.PACKAGE_VERSION }}]",
body: `PR created by Github Actions bot in order to release new version **v${{ env.PACKAGE_VERSION }}**.`
})
return res.data.number;
- name: Request and assign review
uses: actions/github-script@v6
with:
github-token: ${{ github.token }}
script: |
await github.rest.pulls.requestReviewers({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: ${{ steps.pr-create.outputs.result }},
reviewers: ['${{ github.actor }}']
});
await github.rest.issues.addAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: ${{ steps.pr-create.outputs.result }},
assignees: ['${{ github.actor }}']
});
publish:
name: Tagging and publish new release
runs-on: ubuntu-latest
if: (github.event.pull_request.merged == true) && (startsWith(github.event.pull_request.title, 'Release:'))
steps:
- run: |
echo ${{ github.event.pull_request.title}}
echo "TAG=$(echo '${{ github.event.pull_request.title}}' | awk -F '[][]' '{print $2}')" >> $GITHUB_ENV
- name: Checkout
if: "${{ env.TAG }}"
uses: actions/checkout@v4
with:
token: ${{ secrets.REPO_ACCESS }}

- name: Tagging
if: "${{ env.TAG }}"
run: |
git tag ${{ env.TAG }}
git push origin --tags
- name: Create and publish release on tag
if: "${{ env.TAG }}"
uses: actions/github-script@v6
with:
github-token: ${{ github.token }}
script: |
github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: "${{ env.TAG }}",
target_commitish: "${{ github.sha}}",
name: "${{ env.TAG }}"
})
- name: NPM package publish (npmjs registry)
if: "${{ env.TAG }}"
run: |
npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
38 changes: 38 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Test

on:
push:
branches:
- "**"
- "!release**"
tags:
- "v**"

workflow_dispatch:
inputs:
logLevel:
description: "Log level"
required: true
default: "warning"

jobs:
test:
runs-on: ubuntu-latest

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

- uses: actions/setup-node@v4
with:
node-version: "20.x"

- uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- run: npm run test
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,10 @@ dist
# TernJS port file
.tern-port

unreleased/
BAC-*
PR-*
KALI-*
TEST-*
CHANGELOG

.tap
!test/unreleased
5 changes: 5 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules/
.eslintrc.cjs
gitstronaut.jpg
.github/
unreleased/
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
11 changes: 4 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@ FORMAT](https://img.shields.io/badge/Format-keepachangelog-orange.svg)](https://

## [2.0.0] - 2023-09-25

[![TASK](https://img.shields.io/badge/TASK-BAC%20838-default.svg)](https://ctinnovation.atlassian.net/browse/BAC-838) [![TASK](https://img.shields.io/badge/TASK-BAC%20839-default.svg)](https://ctinnovation.atlassian.net/browse/BAC-839)

### Added

- Aggiunta comando `explore` per ottenere una parte di un file `CHANGELOG.md` più grande ‧ [BAC-838](https://ctinnovation.atlassian.net/browse/BAC-838)
- Aggiunta possibilità di stampare il markdown ottenuto su console; aggiunta colori per rendere più leggibile l'output ‧ [BAC-838](https://ctinnovation.atlassian.net/browse/BAC-838)
- Aggiunta flag `createOutputIfNotFound` default a `true`[BAC-839](https://ctinnovation.atlassian.net/browse/BAC-839)
- Aggiunta flag `taskUrlTemplate` per impostare un URL diverso ‧ [BAC-839](https://ctinnovation.atlassian.net/browse/BAC-839)
- Added `explore` command for exploring changelogs generated by this tool
- Added `--createOutputIfNotFound` flag to `generate` command default to `true`
- Added `--taskUrlTemplate` flag to customize task url templates

### Changed

- impostato il comando di default come `generate`[BAC-838](https://ctinnovation.atlassian.net/browse/BAC-838)
- `generate` is now the default command
Loading

0 comments on commit de191bf

Please sign in to comment.