-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ff41a3f
commit fc0caf6
Showing
10 changed files
with
218 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
on: | ||
push: | ||
tags: | ||
- "[0-9]+.[0-9]+.[0-9]+" | ||
|
||
jobs: | ||
create-release: | ||
name: "Create Release" | ||
runs-on: "ubuntu-latest" | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Read Changelog | ||
uses: ./ | ||
id: read | ||
- name: Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
body: ${{ steps.read.outputs.changelog }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,104 +1,2 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
.vscode/ | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# TypeScript v1 declaration files | ||
typings/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Microbundle cache | ||
.rpt2_cache/ | ||
.rts2_cache_cjs/ | ||
.rts2_cache_es/ | ||
.rts2_cache_umd/ | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
.env.test | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
|
||
# Next.js build output | ||
.next | ||
|
||
# Nuxt.js build / generate output | ||
.nuxt | ||
dist | ||
|
||
# Gatsby files | ||
.cache/ | ||
# Comment in the public line in if your project uses Gatsby and *not* Next.js | ||
# https://nextjs.org/blog/next-9-1#public-directory-support | ||
# public | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
.dynamodb/ | ||
|
||
# TernJS port file | ||
.tern-port |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# [1.0.0]() (2021-04-30) | ||
## Initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,68 @@ | ||
# snapaddy-changelog-parser | ||
Github action to parse changelog to create automatic Github releases | ||
# snapADDY Changelog Parser | ||
|
||
A Github Action to parse manually created changelogs for automatic Github Releases. | ||
|
||
This action reads a markdown changelog file, and provides the latest versions release notes to steps further down the pipeline. | ||
|
||
### Simple example: | ||
```yaml | ||
on: | ||
push: | ||
tags: | ||
- "[0-9]+.[0-9]+.[0-9]+" | ||
|
||
jobs: | ||
tagged-release: | ||
name: "Tagged Release" | ||
runs-on: "ubuntu-latest" | ||
|
||
steps: | ||
- name: Read Changelog | ||
uses: snapADDY/[email protected] | ||
id: read | ||
- name: Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
body: ${{ steps.read.outputs.changelog }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
``` | ||
--- | ||
## Required changelog formatting: | ||
Each section hast to start with a `#` followed by a space (markdown H1) and a semver formatted version number. Brackets around the version number are also supported, in case it's a hyperlink. | ||
```markdown | ||
# 1.0.0 | ||
or | ||
# [1.0.0](https://) | ||
``` | ||
|
||
### Example: | ||
This input: | ||
```markdown | ||
# [1.0.0](https://github.com/...) (2021-04-30) | ||
## Features | ||
- CI Magic 🧙♂️ | ||
# [0.1.0](https://github.com/...) (2021-04-27) | ||
## Fixes | ||
- more notes | ||
``` | ||
would return: | ||
```markdown | ||
## Features | ||
- CI Magic 🧙♂️ | ||
``` | ||
|
||
--- | ||
|
||
### Input | ||
| Name | Type | Description | Default | | ||
|---|---|---|---| | ||
| changelog-path | string | Path to the changelog file | `CHANGELOG.md` | | ||
|
||
### Output | ||
| Name | Type | Description | | ||
|---|---|---| | ||
| changelog | string | | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: 'snapADDY Changelog Parser' | ||
author : 'snapADDY GmbH' | ||
description: 'Extract latest entry from markdown formatted changelog' | ||
branding: | ||
icon: 'file-text' | ||
color: 'green' | ||
inputs: | ||
changelog-path: | ||
description: 'path to changelog file' | ||
required: true | ||
default: 'CHANGELOG.md' | ||
outputs: | ||
changelog: | ||
description: 'The changelog for the given tag' | ||
runs: | ||
using: 'node12' | ||
main: 'dist/index.js' |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "snapaddy-changelog-parser", | ||
"version": "1.0.0", | ||
"description": "Parser for CHANGELOG.md to create automatic Github Releases", | ||
"main": "index.ts", | ||
"scripts": { | ||
"build": "npx ncc build -m src/index.ts" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/snapADDY/snapaddy-changelog-parser.git" | ||
}, | ||
"author": "snapADDY GmbH", | ||
"license": "GNU GPL v3", | ||
"bugs": { | ||
"url": "https://github.com/snapADDY/snapaddy-changelog-parser/issues" | ||
}, | ||
"homepage": "https://github.com/snapADDY/snapaddy-changelog-parser#readme", | ||
"dependencies": { | ||
"@actions/core": "^1.2.7" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^15.0.1", | ||
"@vercel/ncc": "^0.28.4", | ||
"typescript": "^4.2.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import * as core from '@actions/core'; | ||
import * as fs from 'fs'; | ||
import * as readline from 'readline'; | ||
|
||
async function run(): Promise<void> { | ||
try { | ||
const filepath = core.getInput('changelog-path'); | ||
const changelog = await readChangelog(filepath); | ||
core.setOutput('changelog', changelog); | ||
|
||
} catch (error) { | ||
core.setFailed(error.message); | ||
} | ||
} | ||
|
||
async function readChangelog(filepath: string): Promise<string> { | ||
const fileStream = fs.createReadStream(filepath); | ||
const rl = readline.createInterface({ | ||
input: fileStream, | ||
crlfDelay: Infinity | ||
}); | ||
|
||
let versionCounter = 0; | ||
const changelogLines: Array<string> = []; | ||
|
||
for await (const line of rl) { | ||
if (/^# \[?[0-9]+\.[0-9]+\.[0-9]+\]?/.test(line)) { | ||
versionCounter++; | ||
if (versionCounter > 1) { | ||
break; | ||
} | ||
} | ||
changelogLines.push(line); | ||
} | ||
return changelogLines.slice(1).join('\n').trim(); | ||
} | ||
|
||
run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"module": "commonjs", | ||
"strict": true, | ||
"moduleResolution": "node", | ||
"esModuleInterop": true, | ||
"skipLibCheck": true, | ||
"forceConsistentCasingInFileNames": true | ||
} | ||
} |