Skip to content

Commit 572b419

Browse files
authored
ci: add a release action like Action's repo (#11)
1 parent 58c4da9 commit 572b419

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

.github/slack_message.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"text": "New version of Taskfile (${{env.VERSION_NUMBER}}) is available",
3+
"blocks": [
4+
{
5+
"type": "header",
6+
"text": {
7+
"type": "plain_text",
8+
"emoji": true,
9+
"text": ":rocket: New version of Taskfile (${{env.VERSION_NUMBER}}) is available"
10+
}
11+
},
12+
{
13+
"type": "section",
14+
"text": {
15+
"type": "mrkdwn",
16+
"text": "What's new ?"
17+
}
18+
},
19+
{
20+
"type": "section",
21+
"text": {
22+
"type": "mrkdwn",
23+
"text": ${{ env.CHANGELOG}}
24+
}
25+
}
26+
]
27+
}

.github/workflows/release.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: release
2+
3+
4+
run-name: Release ${{ github.event.inputs.major_version }} to ${{ github.event.inputs.version_number }} by ${{github.actor}}
5+
env:
6+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_DEPLOYMENT_BOT_TOKEN }}
7+
on:
8+
workflow_dispatch:
9+
inputs:
10+
version_number:
11+
description: 'Release version number (v#.#.#)'
12+
type: string
13+
required: true
14+
major_version:
15+
type: choice
16+
description: The major version to update
17+
options:
18+
- v1
19+
20+
permissions:
21+
actions: write
22+
contents: write
23+
24+
jobs:
25+
release-tag:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0
32+
33+
- name: Git push release tag
34+
run: |
35+
git config user.name github-actions[bot]
36+
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
37+
git tag ${{ inputs.version_number }}
38+
git tag -f v1
39+
git push origin v1 --force
40+
git push origin ${{ inputs.version_number }}
41+
- name: Get changelog
42+
id: get_changelog
43+
run: |
44+
{
45+
echo 'changelog<<EOF'
46+
git --no-pager log --pretty="%h - %s (%an)" $(git tag --sort version:refname | tail -n 2 | head -n 1)..$(git tag --sort version:refname | tail -n 1) | sed -E 's/\n/\\n/g'
47+
echo EOF
48+
} >> "$GITHUB_OUTPUT"
49+
- name: Post to a Slack channel
50+
id: slack
51+
env:
52+
VERSION_NUMBER: ${{github.event.inputs.version_number}}
53+
CHANGELOG: ${{ toJSON(format('```{0}```',steps.get_changelog.outputs.changelog)) }}
54+
uses: slackapi/[email protected]
55+
with:
56+
channel-id: CHUC23F16
57+
payload-file-path: ./.github/slack_message.json
58+

0 commit comments

Comments
 (0)