Skip to content

Commit

Permalink
chore: update workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
ilhan007 committed Oct 28, 2024
1 parent 8d2952c commit 99a73dd
Show file tree
Hide file tree
Showing 16 changed files with 361 additions and 59 deletions.
59 changes: 59 additions & 0 deletions .github/actions/commentOnFixedIssues.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { promises as fs } from 'node:fs';
import { success as issueCommenter } from '@semantic-release/github';

const getRelease = async (version) => {
const releaseInfo = await github.request('GET /repos/{owner}/{repo}/releases/tags/{tag}', {
owner: context.repo.owner,
repo: context.repo.repo,
tag: `v${version}`
});
const release = releaseInfo.data;
release.url = release.html_url;

return release;
};

const getReleaseCommits = (release) => {
const commits = [];

let result;
do {
result = /commit\/(?<sha>\w{40})/gm.exec(release.body);
if (result?.groups?.sha) {
commits.push({ hash: result.groups.sha });
}
} while (result);

return commits;
};

const getOctokitShim = (github) => {
return new Proxy(class {}, {
construct(target, argArray, newTarget) {
return github;
}
});
}

/**
* Publishes comments to issues that are fixed and released.
* @param options.github
* @param options.context
* @returns {Promise<void>}
*/
export default async function run({ github, context }) {
const lerna = await fs.readFile(new URL('../../lerna.json', import.meta.url), 'utf8');
const { version } = JSON.parse(lerna);
const release = await getRelease(version);
const commits = getReleaseCommits(release);
const Octokit = getOctokitShim(github);

await issueCommenter({}, {
options: { repositoryUrl: `https://github.com/${context.repo.owner}/${context.repo.repo}`},
commits,
nextRelease: { version: `v${version}` },
releases: [release],
logger: console,
env: process.env
}, { Octokit });
}
28 changes: 0 additions & 28 deletions .github/actions/createIssueComments.cjs

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/ci-test-storybook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4.0.1
- uses: actions/setup-node@v4.1.0
with:
node-version: 18
node-version: 20
cache: 'yarn'

- name: Install and Build
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-test-website.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4.0.1
- uses: actions/setup-node@v4.1.0
with:
node-version: 18
node-version: 20
cache: 'yarn'

- name: Install and Build
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4.0.1
- uses: actions/setup-node@v4.1.0
with:
node-version: 18
node-version: 20
cache: 'yarn'

- name: Install Dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy-website-manually.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4.0.1
- uses: actions/setup-node@v4.1.0
with:
node-version: 18
node-version: 20
cache: 'yarn'

- name: Install and Build
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy-website-on-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4.0.1
- uses: actions/setup-node@v4.1.0
with:
node-version: 18
node-version: 20
cache: 'yarn'

- name: Install and Build
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/issues-handling.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ jobs:
with:
token: ${{ secrets.UI5_WEBCOMP_BOT_GH_TOKEN }}
fetch-depth: 0
- uses: actions/setup-node@v4.0.1
- uses: actions/setup-node@v4.1.0
with:
node-version: 18
node-version: 20
cache: 'yarn'

- name: Install
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4.0.1
- uses: actions/setup-node@v4.1.0
with:
node-version: 18
node-version: 20
cache: 'yarn'

- name: Install Dependencies
Expand Down
17 changes: 14 additions & 3 deletions .github/workflows/release-downport.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ jobs:
with:
token: ${{ secrets.UI5_WEBCOMP_BOT_GH_TOKEN }}
fetch-depth: 0
- uses: actions/setup-node@v4.0.1
- uses: actions/setup-node@v4.1.0
with:
node-version: 18
node-version: 20
cache: 'yarn'

- name: Install
Expand All @@ -49,4 +49,15 @@ jobs:
NPM_EMAIL: ${{ secrets.NPM_EMAIL }}
NPM_AUTH_TOKEN: ${{ secrets.NPM_RELEASE_AUTH_TOKEN }}
GH_TOKEN: ${{ secrets.UI5_WEBCOMP_BOT_GH_TOKEN }}
run: yarn lerna publish from-git --yes --dist-tag ${{ github.event.inputs.npm_tag }}
run: yarn lerna publish from-git --yes --dist-tag ${{ github.event.inputs.npm_tag }}

- name: Publish Release Comments
uses: actions/github-script@v7
env:
GH_TOKEN: ${{ secrets.UI5_WEBCOMP_BOT_GH_TOKEN }}
with:
github-token: ${{ secrets.UI5_WEBCOMP_BOT_GH_TOKEN }}
script: |
const commentOnFixedIssues = (await import('${{ github.workspace }}/.github/actions/commentOnFixedIssues.mjs')).default;
await commentOnFixedIssues({ github, context })
4 changes: 2 additions & 2 deletions .github/workflows/release-experimental.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4.0.1
- uses: actions/setup-node@v4.1.0
with:
node-version: 18
node-version: 20
cache: 'yarn'

- name: Install
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release-rc-auto.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
with:
token: ${{ secrets.UI5_WEBCOMP_BOT_GH_TOKEN }}
fetch-depth: 0
- uses: actions/setup-node@v4.0.1
- uses: actions/setup-node@v4.1.0
with:
node-version: 18
node-version: 20
cache: 'yarn'

- name: Install
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release-rc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
with:
token: ${{ secrets.UI5_WEBCOMP_BOT_GH_TOKEN }}
fetch-depth: 0
- uses: actions/setup-node@v4.0.1
- uses: actions/setup-node@v4.1.0
with:
node-version: 18
node-version: 20
cache: 'yarn'

- name: Install
Expand Down
15 changes: 13 additions & 2 deletions .github/workflows/release-stable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ jobs:
with:
token: ${{ secrets.UI5_WEBCOMP_BOT_GH_TOKEN }}
fetch-depth: 0
- uses: actions/setup-node@v4.0.1
- uses: actions/setup-node@v4.1.0
with:
node-version: 18
node-version: 20
cache: 'yarn'

- name: Install
Expand Down Expand Up @@ -53,3 +53,14 @@ jobs:
NPM_AUTH_TOKEN: ${{ secrets.NPM_RELEASE_AUTH_TOKEN }}
GH_TOKEN: ${{ secrets.UI5_WEBCOMP_BOT_GH_TOKEN }}
run: yarn lerna publish from-git --yes

- name: Publish Release Comments
uses: actions/github-script@v7
env:
GH_TOKEN: ${{ secrets.UI5_WEBCOMP_BOT_GH_TOKEN }}
with:
github-token: ${{ secrets.UI5_WEBCOMP_BOT_GH_TOKEN }}
script: |
const commentOnFixedIssues = (await import('${{ github.workspace }}/.github/actions/commentOnFixedIssues.mjs')).default;
await commentOnFixedIssues({ github, context })
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"devDependencies": {
"@commitlint/cli": "^16.2.3",
"@commitlint/config-conventional": "^16.2.1",
"@semantic-release/github": "^11.0.0",
"@wdio/devtools-service": "^7.19.7",
"command-line-args": "^5.1.1",
"copy-and-watch": "^0.1.5",
Expand Down
Loading

0 comments on commit 99a73dd

Please sign in to comment.