-
Notifications
You must be signed in to change notification settings - Fork 0
138 lines (123 loc) · 4.43 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
name: Release MultiAnnouncer
on:
pull_request:
types: [closed]
branches:
- main
workflow_dispatch:
inputs:
versionType:
description: 'Select the version bump type for manual trigger'
required: false
default: 'patch'
type: choice
options:
- patch
- minor
- major
jobs:
release:
runs-on: ubuntu-latest
if: >
github.event.pull_request.merged == true ||
github.event_name == 'workflow_dispatch'
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
ref: 'main'
- name: Fetch all tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Bump Version in TOC file (for manual trigger)
if: github.event_name == 'workflow_dispatch'
run: python .github/scripts/bump_version.py ${{ github.event.inputs.versionType }}
env:
VERSION_TYPE: ${{ github.event.inputs.versionType }}
- name: Bump Version in TOC file (for PR merge)
if: github.event.pull_request.merged == true
run: python .github/scripts/bump_version.py auto
env:
VERSION_TYPE: auto
- name: Get the new version number
id: get_version
run: echo "::set-output name=VERSION::$(grep '^## Version:' MultiAnnouncer.toc | cut -d ' ' -f3)"
- name: Commit updated TOC file
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add MultiAnnouncer.toc
git commit -m "Bump version to ${{ steps.get_version.outputs.VERSION }}" || echo "No changes to commit"
git push
- name: Generate CHANGELOG.md
run: |
LAST_TAG=$(git describe --tags --abbrev=0)
echo "## Changelog since $LAST_TAG" > CHANGELOG.md
echo "" >> CHANGELOG.md
git log ${LAST_TAG}..HEAD --pretty=format:"- %s" --reverse >> CHANGELOG.md
- name: Generate release.json
run: |
VERSION=$(grep '^## Version:' MultiAnnouncer.toc | cut -d ' ' -f3)
MAINLINE=$(jq -r '.versions.mainline' .github/versions.json)
WRATH=$(jq -r '.versions.wrath' .github/versions.json)
CLASSIC=$(jq -r '.versions.classic' .github/versions.json)
cat > release.json << EOF
{
"releases": [
{
"name": "MultiAnnouncer",
"version": "$VERSION",
"filename": "MultiAnnouncer-$VERSION.zip",
"nolib": false,
"metadata": [
{
"flavor": "mainline",
"interface": $MAINLINE
},
{
"flavor": "wrath",
"interface": $WRATH
},
{
"flavor": "classic",
"interface": $CLASSIC
}
]
}
]
}
EOF
shell: bash
- name: Generate version-specific TOC files
run: python .github/scripts/generate_toc_versions.py
- name: Zip Addon Files
run: |
mkdir -p package/MultiAnnouncer
rsync -av --exclude='package/' ./* package/MultiAnnouncer/
cd package
zip -r ../MultiAnnouncer-${{ steps.get_version.outputs.VERSION }}.zip MultiAnnouncer/ -x "*.git*" -x "*__pycache__*" -x "*.github*"
cd ..
rm -rf package
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.get_version.outputs.VERSION }}
release_name: Release v${{ steps.get_version.outputs.VERSION }}
body: "New release of MultiAnnouncer."
draft: false
prerelease: false
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./MultiAnnouncer-${{ steps.get_version.outputs.VERSION }}.zip
asset_name: MultiAnnouncer-${{ steps.get_version.outputs.VERSION }}.zip
asset_content_type: application/zip