-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: create release tags for core/ and extras/
- Loading branch information
Showing
1 changed file
with
104 additions
and
0 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,104 @@ | ||
name: "Create release tags for nested modules" | ||
|
||
on: | ||
push: | ||
tags: | ||
- app/v*.*.* | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
tag: | ||
name: "Create tags" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: "Extract tagbase" | ||
id: extract_tagbase | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
const ref = context.ref; | ||
core.info(`context.ref: ${ref}`); | ||
const refPrefix = 'refs/tags/app/'; | ||
if (!ref.startsWith(refPrefix)) { | ||
core.setFailed(`context.ref does not start with ${refPrefix}: ${ref}`); | ||
return; | ||
} | ||
const tagbase = ref.slice(refPrefix.length); | ||
core.info(`tagbase: ${tagbase}`); | ||
core.setOutput('tagbase', tagbase); | ||
- name: "Tagging core/*" | ||
uses: actions/github-script@v7 | ||
env: | ||
INPUT_TAGPREFIX: "core/" | ||
INPUT_TAGBASE: ${{ steps.extract_tagbase.outputs.tagbase }} | ||
with: | ||
script: | | ||
const tagbase = core.getInput('tagbase', { required: true }); | ||
const tagprefix = core.getInput('tagprefix', { required: true }); | ||
const refname = `tags/${tagprefix}${tagbase}`; | ||
core.info(`creating ref ${refname}`); | ||
try { | ||
await github.rest.git.createRef({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
ref: `refs/${refname}`, | ||
sha: context.sha | ||
}); | ||
core.info(`created ref ${refname}`); | ||
return; | ||
} catch (error) { | ||
core.info(`failed to create ref ${refname}: ${error}`); | ||
} | ||
core.info(`updating ref ${refname}`) | ||
try { | ||
await github.rest.git.updateRef({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
ref: refname, | ||
sha: context.sha | ||
}); | ||
core.info(`updated ref ${refname}`); | ||
return; | ||
} catch (error) { | ||
core.setFailed(`failed to update ref ${refname}: ${error}`); | ||
} | ||
- name: "Tagging extras/*" | ||
uses: actions/github-script@v7 | ||
env: | ||
INPUT_TAGPREFIX: "extras/" | ||
INPUT_TAGBASE: ${{ steps.extract_tagbase.outputs.tagbase }} | ||
with: | ||
script: | | ||
const tagbase = core.getInput('tagbase', { required: true }); | ||
const tagprefix = core.getInput('tagprefix', { required: true }); | ||
const refname = `tags/${tagprefix}${tagbase}`; | ||
core.info(`creating ref ${refname}`); | ||
try { | ||
await github.rest.git.createRef({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
ref: `refs/${refname}`, | ||
sha: context.sha | ||
}); | ||
core.info(`created ref ${refname}`); | ||
return; | ||
} catch (error) { | ||
core.info(`failed to create ref ${refname}: ${error}`); | ||
} | ||
core.info(`updating ref ${refname}`) | ||
try { | ||
await github.rest.git.updateRef({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
ref: refname, | ||
sha: context.sha | ||
}); | ||
core.info(`updated ref ${refname}`); | ||
return; | ||
} catch (error) { | ||
core.setFailed(`failed to update ref ${refname}: ${error}`); | ||
} |