-
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.
* Improve the CI/CD process
- Loading branch information
Showing
10 changed files
with
352 additions
and
315 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: "Draft Release" | ||
description: "Creates or updates a draft release" | ||
|
||
inputs: | ||
branch_name: | ||
description: "The target branch name (1.x, 2.x, etc.)" | ||
required: true | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Draft github release | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const script = require('${{ github.action_path }}/script.js') | ||
await script({ | ||
github, | ||
context, | ||
inputs: { | ||
branchName: '${{ inputs.branch_name }}' | ||
} | ||
}) |
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, inputs }) => { | ||
const tagName = `unreleased[${inputs.branchName}]`; | ||
const releases = await github.rest.repos.listReleases({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
tag_name: tagName, | ||
}); | ||
|
||
const filtered = releases.data.filter( | ||
(release) => release.draft == true && release.tag_name === tagName, | ||
); | ||
|
||
if (filtered.length > 0) { | ||
console.log("Deleting old untagged release"); | ||
await github.rest.repos.deleteRelease({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
release_id: filtered[0].id, | ||
}); | ||
|
||
try { | ||
console.log(`Deleting old '${tagName}' tag`); | ||
await github.rest.git.deleteRef({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
ref: `tags/${tagName}`, | ||
}); | ||
console.log(`The '${tagName}' tag has been deleted`); | ||
} catch (error) { | ||
console.log(`Tag '${tagName}' does not exist or could not be deleted`); | ||
} | ||
} | ||
|
||
console.log(`Creating a new untagged release for ${inputs.branchName}`); | ||
await github.rest.repos.createRelease({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
tag_name: tagName, | ||
name: `Unreleased [${inputs.branchName}]`, | ||
draft: true, | ||
generate_release_notes: true, | ||
}); | ||
}; |
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,33 @@ | ||
name: "Set Release Tag" | ||
description: "Updates the tag of specific release" | ||
|
||
inputs: | ||
branch_name: | ||
description: "The target branch name (1.x, 2.x, etc.)" | ||
required: true | ||
tag_name: | ||
description: "The target tag name" | ||
required: true | ||
|
||
outputs: | ||
release_id: | ||
description: "The result from the release tag update operation" | ||
value: ${{ steps.set-release-tag.outputs.result }} | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Set release tag | ||
uses: actions/github-script@v6 | ||
id: set-release-tag | ||
with: | ||
script: | | ||
const script = require('${{ github.action_path }}/script.js') | ||
return await script({ | ||
github, | ||
context, | ||
inputs: { | ||
branchName: '${{ inputs.branch_name }}', | ||
tagName: '${{ inputs.tag_name }}' | ||
} | ||
}) |
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,38 @@ | ||
module.exports = async ({ github, context, inputs }) => { | ||
const releases = await github.rest.repos.listReleases({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
tag_name: "unreleased", | ||
}); | ||
let release = releases.data.find( | ||
(release) => | ||
release.draft == true && | ||
release.tag_name === `unreleased[${inputs.branchName}]`, | ||
); | ||
|
||
if (release) { | ||
console.log("Updating the draft release..."); | ||
github.rest.repos.updateRelease({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
release_id: release.id, | ||
name: inputs.tagName, | ||
tag_name: inputs.tagName, | ||
draft: false, | ||
prerelease: true, | ||
}); | ||
} else { | ||
console.log("Creating a new pre-release..."); | ||
release = github.rest.repos.createRelease({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
name: inputs.tagName, | ||
tag_name: inputs.tagName, | ||
draft: false, | ||
prerelease: true, | ||
generate_release_notes: true, | ||
}); | ||
} | ||
|
||
return release.id; | ||
}; |
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ name: CI Validation | |
on: | ||
pull_request: | ||
branches: | ||
- main | ||
- "[0-9]+.x" | ||
|
||
defaults: | ||
run: | ||
|
This file was deleted.
Oops, something went wrong.
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,24 @@ | ||
name: Draft Release | ||
run-name: Draft Release latest updates of ${{ github.ref_name }} (@${{ github.actor }}) | ||
|
||
on: | ||
push: | ||
branches: | ||
- "[0-9]+.x" | ||
|
||
concurrency: | ||
group: release-${{ github.ref_name }} | ||
cancel-in-progress: false | ||
|
||
jobs: | ||
draft-release: | ||
name: Draft Github Release | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Create/Update Draft Release | ||
uses: ./.github/actions/draft-release | ||
with: | ||
branch_name: ${{ github.ref_name }} |
Oops, something went wrong.