-
Notifications
You must be signed in to change notification settings - Fork 11
66 lines (59 loc) · 2.94 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
name: Make Release
# Create a release on the given branch
# Release and tag name format will be <version>-<branch>
# The body of the release will be created from the changelog.txt or news element in the addon.xml.in
on: workflow_dispatch
jobs:
default:
runs-on: ubuntu-latest
name: Make Release
steps:
# Checkout the current repository into a directory (repositories name)
- name: Checkout Repository
uses: actions/checkout@v2
with:
fetch-depth: 0
path: ${{ github.event.repository.name }}
# Install all dependencies required by the following steps
# - libxml2-utils, xmlstarlet: reading news and version from addon.xml.in
- name: Install dependencies
run: |
sudo apt-get install libxml2-utils xmlstarlet
# Create the variables required by the following steps
# - steps.required-variables.outputs.changes: latest entry in the changelog.txt (if exists), or addon.xml.in news element
# - steps.required-variables.outputs.version: version element from addon.xml.in
# - steps.required-variables.outputs.branch: branch of the triggering ref
- name: Get required variables
id: required-variables
run: |
changes=$(cat "$(find . -name changelog.txt)" | awk -v RS= 'NR==1')
if [ -z "$changes" ] ;
then
changes=$(xmlstarlet fo -R "$(find . -name addon.xml.in)" | xmlstarlet sel -t -v 'string(/addon/extension/news)' | awk -v RS= 'NR==1')
fi
changes="${changes//'%'/'%25'}"
changes="${changes//$'\n'/'%0A'}"
changes="${changes//$'\r'/'%0D'}"
changes="${changes//$'\\n'/'%0A'}"
changes="${changes//$'\\r'/'%0D'}"
echo ::set-output name=changes::$changes
version=$(xmlstarlet fo -R "$(find . -name addon.xml.in)" | xmlstarlet sel -t -v 'string(/addon/@version)')
echo ::set-output name=version::$version
branch=$(echo ${GITHUB_REF#refs/heads/})
echo ::set-output name=branch::$branch
working-directory: ${{ github.event.repository.name }}
# Create a release at {steps.required-variables.outputs.branch}
# - tag and release name format: {steps.required-variables.outputs.version}-{steps.required-variables.outputs.branch} ie. 1.0.0-Matrix
# - release body: {steps.required-variables.outputs.changes}
- name: Create Release
id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.required-variables.outputs.version }}-${{ steps.required-variables.outputs.branch }}
release_name: ${{ steps.required-variables.outputs.version }}-${{ steps.required-variables.outputs.branch }}
body: ${{ steps.required-variables.outputs.changes }}
draft: false
prerelease: false
commitish: ${{ steps.required-variables.outputs.branch }}