Skip to content

Commit 4ecea86

Browse files
committed
Add release flow
1 parent ed2ca23 commit 4ecea86

File tree

2 files changed

+75
-4
lines changed

2 files changed

+75
-4
lines changed

.ci/release-parser.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
3+
# This file is part of the Zephir Parser.
4+
#
5+
# (c) Zephir Team <team@zephir-lang.com>
6+
#
7+
# For the full copyright and license information, please view
8+
# the LICENSE file that was distributed with this source code.
9+
10+
11+
# -e Exit immediately if a command exits with a non-zero status.
12+
# -u Treat unset variables as an error when substituting.
13+
14+
set -eu
15+
set -o pipefail
16+
17+
# Get Release notes for the latest release from CHANGELOG.md
18+
# How to use:
19+
# release-notes.sh CHANGELOG.md
20+
21+
startline=$(cat "$1" | grep -nE "^### " | head -n 1 | cut -d ":" -f 1)
22+
finishline=$(($(cat "$1" | grep -nE "^## \[\d" | head -n 2 | tail -n 1 | cut -d ":" -f 1) - 1))
23+
changelog=$(sed -n "${startline},${finishline}p" "$1");
24+
25+
26+
: "${GITHUB_ACTIONS:=0}"
27+
28+
if [ "$GITHUB_ACTIONS" = "true" ]
29+
then
30+
changelog="${changelog//'%'/'%25'}"
31+
changelog="${changelog//$'\n'/'%0A'}"
32+
changelog="${changelog//$'\r'/'%0D'}"
33+
fi
34+
35+
echo "${changelog}"

.github/workflows/ci.yml

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ env:
2121
EXTENSION_FILE: php_zephir_parser.dll
2222

2323
jobs:
24-
windows:
24+
windows-builds:
2525
# To prevent build a particular commit use
2626
# git commit -m "......... [win skip] - skip Windows builds only"
2727
# git commit -m "......... [ci skip] - skip all builds"
@@ -190,7 +190,7 @@ jobs:
190190
- name: Upload Zephir Parser
191191
uses: actions/upload-artifact@v2
192192
with:
193-
name: zephir-parser-php-${{ matrix.php }}-${{ matrix.build_type }}-win32-${{ matrix.vc_prefix }}${{ matrix.vc_num }}-${{ matrix.arch }}
193+
name: zephir-parser-php-${{ matrix.php }}-${{ matrix.build_type }}-win32-${{ matrix.vc_prefix }}${{ matrix.vc_num }}-${{ matrix.arch }}.zip
194194
path: |
195195
${{ github.workspace }}\zephir-parser-*.zip
196196
@@ -216,7 +216,7 @@ jobs:
216216
${{ github.workspace }}\Release*
217217
${{ github.workspace }}\**\Release*
218218
219-
unix:
219+
unix-builds:
220220
# To prevent build a particular commit use
221221
# git commit -m "......... [unix skip] - skip Linux & macOS builds only"
222222
# git commit -m "......... [ci skip] - skip all builds"
@@ -348,6 +348,42 @@ jobs:
348348
- name: Upload Zephir Parser
349349
uses: actions/upload-artifact@v2
350350
with:
351-
name: zephir-parser-php-${{ matrix.php }}-${{ matrix.build_type }}-${{ runner.os }}-${{ matrix.compiler }}-${{ matrix.arch }}
351+
name: zephir-parser-php-${{ matrix.php }}-${{ matrix.build_type }}-${{ runner.os }}-${{ matrix.compiler }}-${{ matrix.arch }}.zip
352352
path: |
353353
${{ github.workspace }}/modules/*.so
354+
355+
release:
356+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
357+
358+
needs: [windows-builds, unix-builds]
359+
name: Create Release
360+
runs-on: ubuntu-20.04
361+
362+
steps:
363+
- name: Checkout Code
364+
uses: actions/checkout@v2
365+
with:
366+
fetch-depth: 1
367+
368+
- name: Get the release version
369+
id: get-version
370+
run: |
371+
echo ::set-output name=version::${GITHUB_REF#refs/tags/}
372+
echo ::set-output name=release_body::$(.ci/release-notes.sh CHANGELOG.md)
373+
374+
- name: Download Zephir Parser build artifacts
375+
id: download
376+
uses: actions/download-artifact@v2
377+
run: |
378+
ls -lah | grep "\.zip"
379+
380+
- name: Create Release
381+
uses: ncipollo/release-action@v1
382+
with:
383+
token: ${{ secrets.GITHUB_TOKEN }}
384+
name: ${{ steps.get-version.outputs.version }}
385+
tag: ${{ steps.get-version.outputs.version }}
386+
body: ${{ steps.get-version.outputs.release_body }}
387+
allowUpdates: true
388+
artifacts: "${{steps.download.outputs.download-path}}/zephir-parser*.zip"
389+
artifactContentType: application/octet-stream

0 commit comments

Comments
 (0)