-
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.
- Loading branch information
1 parent
4b2c19e
commit 2e8b263
Showing
2 changed files
with
53 additions
and
1 deletion.
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,52 @@ | ||
name: CD | ||
on: | ||
push: | ||
tags: ["v*"] | ||
jobs: | ||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Create release | ||
uses: actions/github-script@v7 | ||
with: | ||
github-token: ${{ secrets.github_token }} | ||
script: | | ||
const tag = process.env.GITHUB_REF.split('/').slice(-1)[0] | ||
const [semVer, prefix, major, minor, patch, prerelease, buildmetadata] = tag.match(/^(v?)(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/) ?? [] | ||
try { | ||
await github.rest.repos.createRelease({ | ||
draft: false, | ||
generate_release_notes: true, | ||
name: tag, | ||
owner: context.repo.owner, | ||
prerelease: false, | ||
repo: context.repo.repo, | ||
tag_name: tag, | ||
}) | ||
} | ||
catch (error) { | ||
core.setFailed(error.message) | ||
} | ||
- name: Update major version | ||
run: | | ||
MAJOR_VERSION="$(cut -d '.' -f 1 <<< "$GITHUB_REF_NAME")" | ||
git config user.name "${GITHUB_ACTOR}" | ||
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" | ||
git tag -fa ${MAJOR_VERSION} -m "Map ${MAJOR_VERSION} to ${GITHUB_REF_NAME}" | ||
git push origin ${MAJOR_VERSION} --force | ||
notify: | ||
needs: [release] | ||
name: Notify | ||
if: always() | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: andrewscwei/telegram-action@v1 | ||
with: | ||
success: ${{ needs.release.result == 'success' }} | ||
cancelled: ${{ needs.release.result == 'cancelled' }} | ||
bot-token: ${{ secrets.TELEGRAM_DEVOPS_BOT_TOKEN }} | ||
chat-id: ${{ secrets.TELEGRAM_DEVOPS_CHAT_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