-
Notifications
You must be signed in to change notification settings - Fork 3
80 lines (68 loc) · 2.54 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: Tag and Create Release Workflow
on:
pull_request:
types:
- closed
jobs:
release:
runs-on: ubuntu-latest
if: startsWith(github.event.pull_request.title, 'Release:')
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Git
run: |
git config user.name "kingmariano"
git config user.email "charlesozochukwu2004@gmail.com"
- name: Get tag
id: get_tag
run: |
git branch --show-current
git pull
echo "version=v$(grep 'const version =' main.go | awk -F\" '{print $2}')" >> $GITHUB_OUTPUT
- name: Tag the commit
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
next_version=${{ steps.get_tag.outputs.version }}
git tag -a "$next_version" -m "Version $next_version"
git push --follow-tags
- name: Create changelog diff
id: changelog_diff
run: |
sed -n "/^## \[${{ steps.get_tag.outputs.version }}\]/,/^## \[$(git describe --abbrev=0 --tags $(git rev-list --tags --skip=1 --max-count=1))\]/{/^## \[$(git describe --abbrev=0 --tags $(git rev-list --tags --skip=1 --max-count=1))\]/!p;}" CHANGELOG.md > release_notes.md
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_tag.outputs.version }}
release_name: Release ${{ steps.get_tag.outputs.version }}
body_path: ./release_notes.md
draft: false
prerelease: false
- name: Create ZIP Archive
run: zip -r source_code.zip .
- name: Create TAR.GZ Archive
run: tar -czvf source_code.tar.gz .
- name: Upload ZIP Archive
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./source_code.zip
asset_name: source_code.zip
asset_content_type: application/zip
- name: Upload TAR.GZ Archive
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./source_code.tar.gz
asset_name: source_code.tar.gz
asset_content_type: application/gzip
- name: Delete release_notes file
run: rm release_notes.md