-
Notifications
You must be signed in to change notification settings - Fork 0
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
2f32118
commit 2c45068
Showing
366 changed files
with
88,223 additions
and
0 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,18 @@ | ||
name: Release a Changelog | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
release_a_changelog: | ||
name: Release a Changelog | ||
runs-on: self-hosted | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Release a Changelog | ||
uses: ./ | ||
with: | ||
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
.idea |
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 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres | ||
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [Unreleased] | ||
|
||
## [v1.0.0] - 2021-05-11 | ||
* 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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Release-a-Changelog action | ||
This GitHub action creates a release based on your `CHANGELOG.md` file. | ||
You must use [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) format or this will not work. | ||
|
||
|
||
# Installation | ||
|
||
Add the following to a new `.github/workflows/release_a_changelog.yml` file (or as part of your existing workflow): | ||
```yaml | ||
name: Release a Changelog | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
release_a_changelog: | ||
name: Release a Changelog | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Release a Changelog | ||
uses: rasmus-saks/[email protected] | ||
with: | ||
github-token: '${{ secrets.GITHUB_TOKEN }}' | ||
``` | ||
> :warning: Make sure you have a `checkout` action before `release-a-changelog`, otherwise it won't be able to read your `CHANGELOG.md` file | ||
|
||
# Usage | ||
1. Add a new version to `CHANGELOG.md` according to [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) | ||
2. Push/merge to master | ||
3. ??? | ||
4. Profit |
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 @@ | ||
name: 'Release a Changelog' | ||
description: 'Creates a GitHub release based on Keep a Changelog' | ||
|
||
runs: | ||
using: node12 | ||
main: 'index.js' | ||
|
||
inputs: | ||
github-token: | ||
description: "GitHub token" | ||
required: true |
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,65 @@ | ||
const core = require('@actions/core'); | ||
const github = require('@actions/github'); | ||
const fs = require('fs'); | ||
|
||
const CHANGELOG_FILE = 'CHANGELOG.md' | ||
const VERSION_REGEX = /## \[(.+)] - (.+)/ | ||
|
||
async function run() { | ||
const octokit = github.getOctokit(core.getInput("github-token")); | ||
const entry = getLatestChangelogEntry() | ||
if (!entry) { | ||
console.log(`Could not find the latest release from ${CHANGELOG_FILE}`) | ||
return | ||
} | ||
|
||
try { | ||
await octokit.repos.getReleaseByTag({ | ||
...github.context.repo, | ||
tag: entry.version | ||
}) | ||
console.log(`A release already exists for ${entry.version}, skipping`) | ||
} catch (error) { | ||
console.log(`Could not find a GitHub release for ${entry.version}, creating one`) | ||
octokit.repos.createRelease({ | ||
...github.context.repo, | ||
tag_name: entry.version, | ||
name: entry.version, | ||
target_commitish: github.context.sha, | ||
body: entry.changelog, | ||
draft: false, | ||
prerelease: false | ||
}) | ||
} | ||
} | ||
|
||
function getLatestChangelogEntry() { | ||
if (fs.existsSync(CHANGELOG_FILE)) { | ||
const content = fs.readFileSync(CHANGELOG_FILE); | ||
const entry = { | ||
version: "", | ||
changelog: "" | ||
} | ||
let inLatestEntry = false | ||
for (const line of content.toString().split(/\r?\n/)) { | ||
const result = line.match(VERSION_REGEX) | ||
if (result) { | ||
if (!inLatestEntry) { | ||
// Started reading the latest entry | ||
inLatestEntry = true; | ||
entry.version = result[1]; | ||
} else { | ||
break; | ||
} | ||
} else if (inLatestEntry) { | ||
entry.changelog += line + "\n"; | ||
} | ||
} | ||
return entry; | ||
} | ||
} | ||
|
||
|
||
run().catch(error => { | ||
core.setFailed(error) | ||
}); |
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.
Oops, something went wrong.