-
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.
* CI内のスクリプトを別ファイルに分離する * super-linterによる指摘事項修正
- Loading branch information
Showing
3 changed files
with
61 additions
and
50 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 |
---|---|---|
|
@@ -11,64 +11,21 @@ runs: | |
- name: Increment version | ||
id: increment_version | ||
uses: actions/[email protected] | ||
env: | ||
SHA: ${{ github.sha }} | ||
with: | ||
github-token: ${{inputs.github-token}} | ||
result-encoding: string | ||
script: | | ||
let latestReleaseVersion = ''; | ||
try { | ||
const getLatestReleaseParams = { | ||
owner: context.repo.owner, | ||
repo: context.repo.repo | ||
}; | ||
console.log("call repos.getLatestRelease:", getLatestReleaseParams); | ||
const latestRelease = await github.rest.repos.getLatestRelease(getLatestReleaseParams); | ||
latestReleaseVersion = latestRelease.data.tag_name; | ||
} catch (e) { | ||
if (e.status === 404) { | ||
latestReleaseVersion = 'v0.0.0'; | ||
} else { | ||
throw e; | ||
} | ||
} | ||
const listPullRequestsAssociatedWithCommitParams = { | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
commit_sha: '${{ github.sha }}', | ||
}; | ||
console.log("call repos.listPullRequestsAssociatedWithCommit:", listPullRequestsAssociatedWithCommitParams); | ||
const pulls = await github.paginate( | ||
github.rest.repos.listPullRequestsAssociatedWithCommit, | ||
listPullRequestsAssociatedWithCommitParams | ||
); | ||
const labels = pulls.flatMap(p => p.labels.map(l => l.name)); | ||
const tagNames = latestReleaseVersion.split('.'); | ||
let version = []; | ||
if (labels.includes('major release')) { | ||
version = [`v${Number(tagNames[0].replace('v', '')) + 1}`, 0, 0]; | ||
} else if (labels.includes('minor release')) { | ||
version = [tagNames[0], Number(tagNames[1]) + 1, 0]; | ||
} else { | ||
version = [tagNames[0], tagNames[1], Number(tagNames[2]) + 1]; | ||
} | ||
return version.join('.'); | ||
const script = require('${{ github.action_path }}/scripts/action/increment_version.js') | ||
return await script({github, context}) | ||
- name: Create release | ||
uses: actions/[email protected] | ||
env: | ||
GITHUB_REF: ${{env.GITHUB_REF}} | ||
TAG_NAME: ${{ steps.increment_version.outputs.result }} | ||
with: | ||
github-token: ${{inputs.github-token}} | ||
script: | | ||
const createReleaseParams = { | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
tag_name: '${{ steps.increment_version.outputs.result }}', | ||
target_commitish: process.env['GITHUB_REF'], | ||
generate_release_notes: true | ||
}; | ||
console.log("call repos.createRelease:", createReleaseParams); | ||
await github.rest.repos.createRelease(createReleaseParams); | ||
const script = require('${{ github.action_path }}/scripts/action/create_release.js') | ||
return await script({github, context}) |
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 @@ | ||
module.exports = async ({ github, context }) => { | ||
const createReleaseParams = { | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
tag_name: process.env.TAG_NAME, | ||
target_commitish: process.env.GITHUB_REF, | ||
generate_release_notes: true | ||
} | ||
console.log('call repos.createRelease:', createReleaseParams) | ||
await github.rest.repos.createRelease(createReleaseParams) | ||
} |
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,43 @@ | ||
module.exports = async ({ github, context }) => { | ||
let latestReleaseVersion = '' | ||
|
||
try { | ||
const getLatestReleaseParams = { | ||
owner: context.repo.owner, | ||
repo: context.repo.repo | ||
} | ||
console.log('call repos.getLatestRelease:', getLatestReleaseParams) | ||
const latestRelease = await github.rest.repos.getLatestRelease(getLatestReleaseParams) | ||
latestReleaseVersion = latestRelease.data.tag_name | ||
} catch (e) { | ||
if (e.status === 404) { | ||
latestReleaseVersion = 'v0.0.0' | ||
} else { | ||
throw e | ||
} | ||
} | ||
|
||
const listPullRequestsAssociatedWithCommitParams = { | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
commit_sha: process.env.SHA | ||
} | ||
console.log('call repos.listPullRequestsAssociatedWithCommit:', listPullRequestsAssociatedWithCommitParams) | ||
const pulls = await github.paginate( | ||
github.rest.repos.listPullRequestsAssociatedWithCommit, | ||
listPullRequestsAssociatedWithCommitParams | ||
) | ||
const labels = pulls.flatMap(p => p.labels.map(l => l.name)) | ||
const tagNames = latestReleaseVersion.split('.') | ||
let version | ||
|
||
if (labels.includes('major release')) { | ||
version = [`v${Number(tagNames[0].replace('v', '')) + 1}`, 0, 0] | ||
} else if (labels.includes('minor release')) { | ||
version = [tagNames[0], Number(tagNames[1]) + 1, 0] | ||
} else { | ||
version = [tagNames[0], tagNames[1], Number(tagNames[2]) + 1] | ||
} | ||
|
||
return version.join('.') | ||
} |