Skip to content

Commit

Permalink
feat: Add tag release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
nlemoine committed Oct 14, 2024
1 parent d73e921 commit f2a896c
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
on:
workflow_call:

permissions:
contents: write

jobs:
tag-release:
runs-on: ubuntu-latest
steps:
- name: Get branch names
id: branch-names
uses: tj-actions/branch-names@v8

- name: Checkout
if: ${{ steps.branch-names.outputs.current_branch == 'update-dependencies' }}
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Get git commit header
if: ${{ steps.branch-names.outputs.current_branch == 'update-dependencies' }}
id: commit-header
run: |
echo "commit_header=$(git show -s --format=%s)" >> $GITHUB_OUTPUT
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
cb="$(git show -s --format=%b)"
echo "commit_body<<EOF"$'\n'"$cb"$'\n'EOF >> $GITHUB_OUTPUT
- uses: actions/github-script@v7
if: ${{ steps.branch-names.outputs.current_branch == 'update-dependencies' }}
id: release-tag
env:
COMMIT_HEADER: ${{ steps.commit-header.outputs.commit_header }}
with:
result-encoding: string
script: |
const commitHeader = process.env.COMMIT_HEADER;
const dateRe = new RegExp(/([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]) (0[0-9]|1[0-9]|2[1-4]):(0[0-9]|[1-5][0-9]))/);
const dateResults = dateRe.exec(commitHeader);
if (dateResults === null) {
return '';
}
return dateResults[0].replace(/:/g, '-').replace(/ /g, '.');
- name: Tag
if: ${{ steps.release-tag.outputs.result != '' }}
run: |
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git tag -a "${{ steps.release-tag.outputs.result }}" -m "${{ steps.release-tag.outputs.result }}"
git push origin "${{ steps.release-tag.outputs.result }}"
- name: Create release
if: ${{ steps.release-tag.outputs.result != '' }}
uses: softprops/action-gh-release@v2
with:
body: ${{ steps.commit-header.outputs.commit_body }}
name: ${{ steps.release-tag.outputs.result }}
tag_name: "${{ steps.release-tag.outputs.result }}"

0 comments on commit f2a896c

Please sign in to comment.