forked from fbelavenuto/arpl-addons
-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (60 loc) · 2.08 KB
/
main.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
name: Build addons
on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: 'format %y.%-m.$i or auto'
required: false
type: string
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@main
- name: Init Env
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
sudo timedatectl set-timezone "Europe/Paris"
- name: Calculate version
run: |
# Calculate version
VERSION=""
if [ ${{ github.event_name }} == 'release' -a ${{ github.ref_type }} == 'tag' ]; then
VERSION="${{ github.ref_name }}"
elif [ -n "${{ inputs.version }}" ]; then
if [ "`echo ${{ inputs.version }} | cut -d '.' -f 1,2`" = "`date +'%y.%-m'`" ]; then
VERSION="${{ inputs.version }}"
else
LATEST_TAG="`curl -skL "https://api.github.com/repos/${{ github.repository }}/releases/latest" | jq -r ".tag_name" 2>/dev/null`"
if [ -n "${LATEST_TAG}" -a "`echo ${LATEST_TAG} | cut -d '.' -f 1,2`" = "`date +'%y.%-m'`" ]; then # format %y.%-m.$i
VERSION="`echo ${LATEST_TAG} | awk -F '.' '{$3=$3+1}1' OFS='.'`"
else
VERSION="`date +'%y.%-m'`.0"
fi
fi
else
VERSION=""
fi
echo "VERSION: ${VERSION}"
echo "VERSION=${VERSION}" >> $GITHUB_ENV
- name: Build addon packages
run: |
./compile-addons.sh
echo "${{ env.VERSION }}" > "VERSION"
zip -9 addons.zip -j *.addon VERSION
- name: Upload to Artifacts
uses: actions/upload-artifact@v3
with:
name: addons
path: |
addons.zip
- name: Release
uses: softprops/action-gh-release@v1
if: env.VERSION != ''
with:
tag_name: ${{ env.VERSION }}
files: addons.zip