-
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
Showing
4 changed files
with
140 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 |
---|---|---|
@@ -1 +1,2 @@ | ||
.idea | ||
node_modules |
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: 'Release Action' | ||
description: 'Creates github releases' | ||
inputs: | ||
release-files: | ||
description: 'Files to attach to the release' | ||
required: false | ||
version-file: | ||
description: 'File containing the current version' | ||
required: true | ||
default: "VERSION" | ||
change-log: | ||
description: 'File containing the change log' | ||
required: true | ||
default: "ChangeLog" | ||
runs: | ||
using: 'node12' | ||
main: 'dist/index.js' |
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,66 @@ | ||
const core = require('@actions/core'); | ||
const {GitHub, context} = require('@actions/github'); | ||
const fs = require('fs') | ||
|
||
try { | ||
const github = new GitHub(process.env.GITHUB_TOKEN); | ||
|
||
// TODO(jpoole): validate this is a semver version | ||
const version = fs.readFileSync("VERSION").toString().trim() | ||
const changeLog = fs.readFileSync("ChangeLog").toString() | ||
|
||
const changes = findTagChangelogs(changeLog, version) | ||
|
||
github.repos.createRelease({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
tag_name: "v"+version, | ||
name: "v"+version, | ||
body: changes, | ||
prerelease: version.includes("beta") || version.includes("alpha") || version.includes("prerelease"), | ||
target_commitish: context.sha, | ||
}).catch(error => { | ||
core.setFailed(error.message); | ||
}) | ||
} catch (error) { | ||
core.setFailed(error.message); | ||
} | ||
|
||
function findTagChangelogs(changelog, tag) { | ||
const versionString = "Version " + tag | ||
|
||
const lines = changelog.split("\n") | ||
let foundVersion = false | ||
let logs = [] | ||
for(let i = 0; i < lines.length; i++) { | ||
let line = lines[i] | ||
if (line.startsWith(versionString)) { | ||
foundVersion = true | ||
continue | ||
} | ||
if (!foundVersion) { | ||
continue | ||
} | ||
|
||
if (line.startsWith("Version")) { | ||
return logs.join("\n") | ||
} | ||
|
||
if (line.startsWith("-")) { | ||
continue | ||
} | ||
|
||
line = line.trim() | ||
if (line === "") { | ||
continue | ||
} | ||
if (line.startsWith("*")) { | ||
logs.push(line) | ||
} else { | ||
logs.push(" " + line) | ||
} | ||
} | ||
return undefined | ||
} | ||
|
||
exports.findTagChangelogs = findTagChangelogs |
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,56 @@ | ||
const release = require("./release") | ||
|
||
const testTest = ` | ||
Version 16.6.0 | ||
-------------- | ||
* Fixed issue with \`go_module()\` where adding the root package removed | ||
all other items in the install list that came before #2019 | ||
* Fixed the linker flags in \`pip_library()\` for macOS #2015 | ||
* Added \`ExcludeGlob\` config option to the \`[Cover]\` section that | ||
excludes files from coverage based on a glob pattern #2020 #2023 | ||
* Fix issue with \`go_module()\` where the incorrect release flags | ||
were being applied when filtering third party go sourcews #2024 | ||
Version 16.5.1 | ||
-------------- | ||
* Fix nil pointer when tests fail in certain ways #2016 | ||
Version 16.5.0 | ||
-------------- | ||
* Singleflight all subincludes removing any potential for lockups #2002 | ||
* Implemented target level locking enabling multiple please instances to | ||
build at the same time #2004 | ||
* Set a timeout on test result uploading #2008 | ||
* Updated to use go 1.17. This should be transparent to any users. #2010 | ||
* Various fixes and improvements around bash completions #1998 #2013 | ||
Version 16.4.2 | ||
-------------- | ||
* Honour require/provide for \`plz query revdeps\` and \`plz query changes\` #1997 | ||
* Fix \`plz tool langserver\` #1999 | ||
Version 16.4.1 | ||
-------------- | ||
* Fixed panic when downloading outputs for stamped targets that were retrived from | ||
the cache #1994 | ||
` | ||
|
||
const exepctedResult = ` | ||
* Singleflight all subincludes removing any potential for lockups #2002 | ||
* Implemented target level locking enabling multiple please instances to | ||
build at the same time #2004 | ||
* Set a timeout on test result uploading #2008 | ||
* Updated to use go 1.17. This should be transparent to any users. #2010 | ||
* Various fixes and improvements around bash completions #1998 #2013 | ||
` | ||
|
||
test("releaseParseTest", () => { | ||
const result = release.findTagChangelogs(testTest, "16.5.0").trim() | ||
expect(result).toContain(exepctedResult.trim()) | ||
}) |