Skip to content

Commit a99c236

Browse files
author
Enda Phelan
committed
first commit
0 parents  commit a99c236

File tree

8 files changed

+4020
-0
lines changed

8 files changed

+4020
-0
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.vscode
2+
3+
logs
4+
*.log
5+
npm-debug.log*
6+
yarn-debug.log*
7+
yarn-error.log*
8+
lerna-debug.log*
9+
/node_modules
10+
/lib

.prettierrc.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
{
3+
"printWidth": 120,
4+
"tabWidth": 2,
5+
"useTabs": false,
6+
"semi": true,
7+
"singleQuote": true,
8+
"trailingComma": "none",
9+
"bracketSpacing": false,
10+
"arrowParens": "avoid",
11+
"parser": "typescript"
12+
}

dist/index.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
module.exports =
2+
/******/ (() => { // webpackBootstrap
3+
/******/ "use strict";
4+
/******/ var __webpack_modules__ = ({
5+
6+
/***/ 109:
7+
/***/ (() => {
8+
9+
10+
console.log("Hello");
11+
//# sourceMappingURL=main.js.map
12+
13+
/***/ })
14+
15+
/******/ });
16+
/************************************************************************/
17+
/******/ // The module cache
18+
/******/ var __webpack_module_cache__ = {};
19+
/******/
20+
/******/ // The require function
21+
/******/ function __webpack_require__(moduleId) {
22+
/******/ // Check if module is in cache
23+
/******/ if(__webpack_module_cache__[moduleId]) {
24+
/******/ return __webpack_module_cache__[moduleId].exports;
25+
/******/ }
26+
/******/ // Create a new module (and put it into the cache)
27+
/******/ var module = __webpack_module_cache__[moduleId] = {
28+
/******/ // no module.id needed
29+
/******/ // no module.loaded needed
30+
/******/ exports: {}
31+
/******/ };
32+
/******/
33+
/******/ // Execute the module function
34+
/******/ var threw = true;
35+
/******/ try {
36+
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
37+
/******/ threw = false;
38+
/******/ } finally {
39+
/******/ if(threw) delete __webpack_module_cache__[moduleId];
40+
/******/ }
41+
/******/
42+
/******/ // Return the exports of the module
43+
/******/ return module.exports;
44+
/******/ }
45+
/******/
46+
/************************************************************************/
47+
/******/ /* webpack/runtime/compat */
48+
/******/
49+
/******/ __webpack_require__.ab = __dirname + "/";/************************************************************************/
50+
/******/ // module exports must be returned from runtime so entry inlining is disabled
51+
/******/ // startup
52+
/******/ // Load entry module and return exports
53+
/******/ return __webpack_require__(109);
54+
/******/ })()
55+
;

package.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "git-chglog-action",
3+
"description": "GitHub Action for git-chglog",
4+
"version": "0.1.0",
5+
"main": "lib/main.js",
6+
"scripts": {
7+
"build": "tsc && ncc build",
8+
"test": "jest --coverage",
9+
"format": "prettier --write **/*.ts",
10+
"format-check": "prettier --check **/*.ts",
11+
"pre-checkin": "yarn run format && yarn run build"
12+
},
13+
"keywords": [
14+
"actions",
15+
"git-chglog",
16+
"github",
17+
"changelog"
18+
],
19+
"author": "Enda Phelan",
20+
"license": "MIT",
21+
"dependencies": {
22+
"@actions/core": "^1.2.7",
23+
"@actions/exec": "^1.0.4",
24+
"@actions/http-client": "^1.0.11",
25+
"@actions/tool-cache": "^1.6.1"
26+
},
27+
"devDependencies": {
28+
"@types/jest": "^26.0.14",
29+
"@types/node": "^14.11.2",
30+
"@vercel/ncc": "^0.24.1",
31+
"dotenv": "^8.2.0",
32+
"jest": "^26.4.2",
33+
"jest-circus": "^26.4.2",
34+
"jest-runtime": "^26.4.2",
35+
"prettier": "^2.1.2",
36+
"tmp": "^0.2.1",
37+
"ts-jest": "^26.4.1",
38+
"typescript": "^4.0.3",
39+
"typescript-formatter": "^7.2.2"
40+
}
41+
}

src/github.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import * as httpm from '@actions/http-client';
2+
import * as core from '@actions/core';
3+
import * as semver from 'semver';
4+
5+
export interface GitHubRelease {
6+
id: number;
7+
tag_name: string;
8+
}
9+
10+
export const getRelease = async (version: string): Promise<GitHubRelease | null> => {
11+
const resolvedVersion: string = (await resolveVersion(version)) || version;
12+
const url: string = `https://github.com/goreleaser/goreleaser/releases/${resolvedVersion}`;
13+
const http: httpm.HttpClient = new httpm.HttpClient('goreleaser-action');
14+
return (await http.getJson<GitHubRelease>(url)).result;
15+
};
16+
17+
const resolveVersion = async (version: string): Promise<string | null> => {
18+
const allTags: Array<string> | null = await getAllTags();
19+
if (!allTags) {
20+
throw new Error(`Cannot find GoReleaser tags`);
21+
}
22+
core.debug(`Found ${allTags.length} tags in total`);
23+
24+
return semver.maxSatisfying(allTags, version);
25+
};
26+
27+
interface GitHubTag {
28+
tag_name: string;
29+
}
30+
31+
const getAllTags = async (): Promise<Array<string>> => {
32+
const http: httpm.HttpClient = new httpm.HttpClient('goreleaser-action');
33+
const url: string = `https://goreleaser.com/static/releases.json`;
34+
const getTags = http.getJson<Array<GitHubTag>>(url);
35+
36+
return getTags.then(response => {
37+
if (response.result == null) {
38+
return [];
39+
}
40+
41+
return response.result.map(obj => obj.tag_name);
42+
});
43+
};

src/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log("Hello")

tsconfig.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es6",
4+
"module": "commonjs",
5+
"lib": [
6+
"es6",
7+
"dom"
8+
],
9+
"newLine": "lf",
10+
"outDir": "./lib",
11+
"rootDir": "./src",
12+
"strict": true,
13+
"noImplicitAny": false,
14+
"esModuleInterop": true,
15+
"sourceMap": true
16+
},
17+
"exclude": ["node_modules", "**/*.test.ts"]
18+
}

0 commit comments

Comments
 (0)