Skip to content

Commit b4774d1

Browse files
Merge pull request #1159 from Adyen/automation/release
Release v14.0.0
2 parents cb8de0b + 78b6393 commit b4774d1

File tree

1,051 files changed

+28634
-9297
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,051 files changed

+28634
-9297
lines changed

.eslintrc.js

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,8 @@
1-
/*
2-
* ######
3-
* ######
4-
* ############ ####( ###### #####. ###### ############ ############
5-
* ############# #####( ###### #####. ###### ############# #############
6-
* ###### #####( ###### #####. ###### ##### ###### ##### ######
7-
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
8-
* ###### ###### #####( ###### #####. ###### ##### ##### ######
9-
* ############# ############# ############# ############# ##### ######
10-
* ############ ############ ############# ############ ##### ######
11-
* ######
12-
* #############
13-
* ############
14-
* Adyen NodeJS API Library
15-
* Copyright (c) 2020 Adyen B.V.
16-
* This file is open source and available under the MIT license.
17-
* See the LICENSE file for more info.
18-
*/
19-
201
const path = require('path');
212

223
module.exports = {
234
parser: "@typescript-eslint/parser",
24-
plugins: ["@typescript-eslint"],
5+
plugins: ["@typescript-eslint", "unused-imports"],
256
env: {
267
es6: true,
278
node: true
@@ -51,7 +32,8 @@ module.exports = {
5132
"{}": false
5233
}
5334
}
54-
]
35+
],
36+
"unused-imports/no-unused-imports": "warn",
5537
},
5638
overrides: [
5739
{

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @Adyen/api-libraries-reviewers
1+
* @Adyen/integration-tools-testing

.github/scripts/release.js renamed to .github/scripts/release.js.1

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,38 @@
1-
// Get the current version of a Node.js package
2-
exports.packageVersion = () => {
3-
return require('../../package.json').version;
4-
};
5-
61
// List of merged pull requests in Markdown
72
exports.changelog = (changeset) => {
8-
let entries = [];
3+
let entries = new Set();
4+
95
for (const { node: { associatedPullRequests: prs } } of changeset.repository.ref.compare.commits.edges) {
106
for (const { node: { number: number } } of prs.edges) {
11-
entries.push(`- #${number}`);
7+
entries.add(number);
128
}
139
}
14-
return entries;
10+
11+
return Array.from(entries).sort((a, b) => a - b).map(pr => `- #${pr}`);
1512
};
1613

1714
// Next semantic version number
18-
exports.nextVersion = (current, increment) => {
15+
exports.nextVersion = (current, increment, preRelease) => {
1916
let [major, minor, patch] = current.split('.');
17+
let [unstaged, stage] = current.split('-');
18+
preRelease = preRelease === "true";
19+
20+
// end pre-release
21+
if (!preRelease && stage) {
22+
return unstaged;
23+
}
24+
25+
// bump pre-release
26+
if (preRelease && stage) {
27+
let [_, stageVersion] = stage.split('.');
28+
stageVersion = parseInt(stageVersion);
29+
if (isNaN(stageVersion)) {
30+
stageVersion = 0;
31+
}
32+
stageVersion++;
33+
return `${unstaged}-beta.${stageVersion}`;
34+
}
35+
2036
switch (increment) {
2137
case 'patch':
2238
patch++;
@@ -31,7 +47,15 @@ exports.nextVersion = (current, increment) => {
3147
patch = 0;
3248
break;
3349
}
34-
return [major, minor, patch].join('.');
50+
51+
let version = [major, minor, patch].join('.');
52+
53+
// start pre-release
54+
if (preRelease && !stage) {
55+
return `${version}-beta`;
56+
}
57+
58+
return version;
3559
};
3660

3761
// Compare two branches on Github
@@ -65,7 +89,7 @@ exports.compareBranches = async (github, { owner, repo, base, head }) => {
6589
}
6690
}
6791
}
68-
}
92+
}
6993
`, { owner, repo, base, head });
7094
}
7195

@@ -78,7 +102,7 @@ exports.detectChanges = (changeset) => {
78102

79103
let increment = 'patch';
80104

81-
// increment based on the merged PR labels
105+
// increment based on the merged PR labels
82106
for (const { node: { associatedPullRequests: prs } } of changeset.repository.ref.compare.commits.edges) {
83107
for (const { node: { labels: { nodes: labels } } } of prs.edges) {
84108
for (const { name: label } of labels) {
@@ -99,7 +123,7 @@ exports.detectChanges = (changeset) => {
99123
};
100124

101125
// Define next release
102-
exports.bump = async ({ github, context, core, getCurrentVersion }) => {
126+
exports.bump = async ({ github, context, core }) => {
103127
const changeset = await this.compareBranches(github, {
104128
owner: context.repo.owner,
105129
repo: context.repo.repo,
@@ -108,9 +132,9 @@ exports.bump = async ({ github, context, core, getCurrentVersion }) => {
108132
});
109133
const changelog = this.changelog(changeset);
110134
const increment = this.detectChanges(changeset);
111-
const nextVersion = this.nextVersion(getCurrentVersion(), increment);
135+
const nextVersion = this.nextVersion(process.env.CURRENT_VERSION, increment, process.env.PRE_RELEASE);
112136

113137
core.setOutput('increment', increment);
114138
core.setOutput('nextVersion', nextVersion);
115139
core.setOutput('changelog', changelog.join("\n"));
116-
};
140+
};

.github/scripts/release.test.js

Lines changed: 53 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// deps='octokit @actions/core'; npm install -g $deps && npm link $deps
22
// node --test .github/scripts/
3-
const test = require('node:test');
3+
const { test, beforeEach } = require('node:test');
44
const assert = require('node:assert/strict');
55
const { Octokit } = require("octokit");
66
const core = require("@actions/core");
@@ -25,6 +25,27 @@ const comparisonFixture = {
2525
"aheadBy": 8,
2626
"commits": {
2727
"edges": [
28+
{
29+
"node": {
30+
"message": "Another commit in the same PR non squashed",
31+
"associatedPullRequests": {
32+
"edges": [
33+
{
34+
"node": {
35+
"number": 20,
36+
"labels": {
37+
"nodes": [
38+
{
39+
"name": "Breaking change"
40+
}
41+
]
42+
}
43+
}
44+
}
45+
]
46+
}
47+
}
48+
},
2849
{
2950
"node": {
3051
"message": "Fixing the constructor",
@@ -91,6 +112,11 @@ const comparisonFixture = {
91112
}
92113
};
93114

115+
beforeEach(() => {
116+
// Reset env variables
117+
delete process.env.CURRENT_VERSION;
118+
delete process.env.PRE_RELEASE;
119+
});
94120

95121
test('Changelog', t => {
96122
const changelog = release.changelog(comparisonFixture);
@@ -132,12 +158,6 @@ test('Detect changes', async t => {
132158
});
133159
});
134160

135-
test('Node.js package version', t => {
136-
const version = release.packageVersion();
137-
138-
assert.ok(version);
139-
});
140-
141161
test('Get next version', async t => {
142162
await t.test('Major', async t => {
143163
const ver = release.nextVersion('13.1.2', 'major');
@@ -162,6 +182,30 @@ test('Get next version', async t => {
162182

163183
assert.strictEqual(ver, '1.2.3');
164184
});
185+
186+
await t.test('Start pre-release', async t => {
187+
const ver = release.nextVersion('14.1.5', 'major', 'true');
188+
189+
assert.strictEqual(ver, '15.0.0-beta');
190+
});
191+
192+
await t.test('Bump first pre-release', async t => {
193+
const ver = release.nextVersion('15.0.0-beta', 'minor', 'true');
194+
195+
assert.strictEqual(ver, '15.0.0-beta.1');
196+
});
197+
198+
await t.test('Bump second pre-release', async t => {
199+
const ver = release.nextVersion('15.0.0-beta.1', 'patch', 'true');
200+
201+
assert.strictEqual(ver, '15.0.0-beta.2');
202+
});
203+
204+
await t.test('End pre-release', async t => {
205+
const ver = release.nextVersion('15.0.0-beta', 'major', 'false');
206+
207+
assert.strictEqual(ver, '15.0.0');
208+
});
165209
});
166210

167211
test('Compare branches', async t => {
@@ -179,8 +223,8 @@ test('Compare branches', async t => {
179223
test('Bump', async t => {
180224
t.mock.method(github, 'graphql', () => comparisonFixture);
181225
t.mock.method(core, 'setOutput', t.mock.fn());
182-
const currentVersion = () => '1.2.3';
183-
const options = { github, context, core, getCurrentVersion: currentVersion };
226+
process.env.CURRENT_VERSION = '1.2.3';
227+
const options = { github, context, core };
184228

185229
await release.bump(options);
186230

.github/workflows/gh-release.yml

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,16 @@
11
name: Github Release
22

33
on:
4-
workflow_dispatch:
5-
push:
6-
branches:
7-
- main
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
88

99
jobs:
1010
gh_release:
1111
permissions:
1212
contents: write
13-
runs-on: ubuntu-latest
14-
steps:
15-
- uses: actions/checkout@v3
16-
with:
17-
fetch-depth: 0
18-
token: ${{ secrets.ADYEN_AUTOMATION_BOT_ACCESS_TOKEN }}
19-
- name: Grab version
20-
uses: actions/github-script@v6
21-
id: release
22-
with:
23-
script: |
24-
const release = require('./.github/scripts/release.js')
25-
core.setOutput('version', release.packageVersion())
26-
- name: Create new release
27-
env:
28-
GH_TOKEN: ${{ secrets.ADYEN_AUTOMATION_BOT_ACCESS_TOKEN }}
29-
run: |
30-
gh release create v${{steps.release.outputs.version}} \
31-
--title 'Adyen Node API Library v${{steps.release.outputs.version}}' \
32-
--generate-notes --target main
33-
- name: Update develop branch
34-
run: |
35-
git checkout develop
36-
git merge main
37-
git push origin develop
13+
uses: ./.github/workflows/lib-gh-release.yml
14+
with:
15+
project-name: Node
16+
secrets: inherit

.github/workflows/lib-gh-release.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
project-name:
5+
required: true
6+
type: string
7+
8+
jobs:
9+
gh_release:
10+
permissions:
11+
contents: write
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
with:
16+
fetch-depth: 0
17+
token: ${{ secrets.ADYEN_AUTOMATION_BOT_ACCESS_TOKEN }}
18+
- name: Grab current version
19+
id: current-version
20+
run: make version
21+
- name: Create new release
22+
env:
23+
GH_TOKEN: ${{ secrets.ADYEN_AUTOMATION_BOT_ACCESS_TOKEN }}
24+
CURRENT_VERSION: ${{steps.current-version.outputs.currentVersion}}
25+
run: |
26+
prerelease=$(node -pe "process.env.CURRENT_VERSION.includes('-') ? '--prerelease' : ''")
27+
gh release create "v${CURRENT_VERSION}" \
28+
--title "Adyen ${{ inputs.project-name }} API Library v${CURRENT_VERSION}" \
29+
--generate-notes $prerelease --target main
30+
- name: Update develop branch
31+
run: |
32+
git checkout develop
33+
git merge origin/main
34+
git push origin develop

0 commit comments

Comments
 (0)