-
Notifications
You must be signed in to change notification settings - Fork 2
80 lines (71 loc) · 2.53 KB
/
release-addon.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
# This workflow releases addon when there is a new version available.
name: Release addon
on:
workflow_dispatch:
jobs:
release-addon:
name: Release addon
runs-on: ubuntu-latest
steps:
- name: Check out branch
uses: actions/checkout@v3
with:
ref: ${{ github.ref_name }}
fetch-depth: 0
- name: Parse addon id/version
shell: bash
run: |
XMLTAG=`grep -e "<addon" ./addon.xml`
RE='^.+id=\"([^"]+)\".+version=\"([^"]+)\".+$'
if [[ $XMLTAG =~ $RE ]]; then
echo "ADDON_ID=${BASH_REMATCH[1]}" >> $GITHUB_ENV
echo "ADDON_VERSION=${BASH_REMATCH[2]}" >> $GITHUB_ENV
fi
- name: Set up release
shell: bash
run: |
TAG_NAME="v${{ env.ADDON_VERSION }}"
RELEASE_NAME="${TAG_NAME} (`date +%Y-%m-%d`)"
echo "TAG_NAME=${TAG_NAME}" >> $GITHUB_ENV
echo "RELEASE_NAME=${RELEASE_NAME}" >> $GITHUB_ENV
if [[ -n "$(git tag -l '${TAG_NAME}')" ]]; then
echo "Cancelling... version already released!"
exit 1
fi
- name: Create release
id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.TAG_NAME }}
release_name: ${{ env.RELEASE_NAME }}
draft: true # todo: debug only
- name: Clean up non-package files
shell: bash
run: |
find . -name '.git' -type d -exec rm -rf {} +
find . -name '.github' -type d -exec rm -rf {} +
find . -name '.idea' -type d -exec rm -rf {} +
find . -name 'tests' -type d -exec rm -rf {} +
find . -name '.gitignore' -type f -exec rm -rf {} +
find . -name 'requirements.txt' -type f -exec rm -rf {} +
- name: Create addon zip package
shell: bash
run: |
cd ..
PACKAGE_NAME="${{ env.ADDON_ID }}-${{ env.ADDON_VERSION }}.zip"
PACKAGE_PATH="`pwd`/${PACKAGE_NAME}"
DIR="${{ env.ADDON_ID }}/"
zip -r -v "./${PACKAGE_NAME}" "./${DIR}"
echo "PACKAGE_NAME=${PACKAGE_NAME}" >> $GITHUB_ENV
echo "PACKAGE_PATH=${PACKAGE_PATH}" >> $GITHUB_ENV
- name: Attach addon zip package to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_content_type: application/zip
asset_name: ${{ env.PACKAGE_NAME }}
asset_path: ${{ env.PACKAGE_PATH }}