-
Notifications
You must be signed in to change notification settings - Fork 10
153 lines (136 loc) · 4.88 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: 'release'
on:
push:
tags: [ '*' ]
jobs:
lint:
runs-on: ubuntu-latest
strategy:
matrix:
php:
- "8.0"
- "8.1"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
steps:
- uses: actions/checkout@v2
id: code-checkout
- name: Validate composer.json and composer.lock
id: composer-validate
run: composer validate
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-lint-php-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-lint-php-${{ matrix.php }}-
- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
id: install-dependencies
uses: php-actions/composer@v5
with:
php_version: ${{ matrix.php }}
args: --prefer-dist --no-progress --no-suggest
- name: PHPCS checker
id: php-codesniffer
run: vendor/squizlabs/php_codesniffer/bin/phpcs
- uses: act10ns/slack@v1
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: '#yap'
if: failure()
create_release:
runs-on: ubuntu-latest
needs: [ lint ]
name: Create release
permissions:
contents: write
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- uses: actions/checkout@v2
id: code-checkout
- name: Generate release notes
id: generate_release_notes
run: |
curl -LO https://raw.githubusercontent.com/bmlt-enabled/release-notes-tool/master/gh-release-notes.sh
chmod +x gh-release-notes.sh
./gh-release-notes.sh RELEASENOTES.md "###"
RELEASE_TYPE=$(if [[ "$GITHUB_REF_NAME" =~ "beta" ]]; then echo "true"; else echo "false"; fi)
echo "RELEASE_TYPE=${RELEASE_TYPE}" >> $GITHUB_ENV
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body_path: "changelog.txt"
prerelease: ${{ env.RELEASE_TYPE }}
package:
runs-on: ubuntu-latest
strategy:
matrix:
php:
- "8.0"
needs: [ lint, create_release ]
steps:
- uses: actions/checkout@v2
id: code-checkout
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php }}-
- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
id: install-dependencies
uses: php-actions/composer@v5
with:
php_version: ${{ matrix.php }}
args: --prefer-dist --no-dev --no-progress --no-suggest
- name: Build package
id: build-package
run: |
export ARTIFACT_FILE=yap-${GITHUB_REF##*/}
export ARTIFACT_FILENAME=${ARTIFACT_FILE}.zip
git archive --format=zip --output=${ARTIFACT_FILENAME} --prefix=${ARTIFACT_FILE}/ HEAD
DISABLE_NOTIFIER=true make deploy
unzip ${ARTIFACT_FILENAME}
rm ${ARTIFACT_FILENAME}
echo ${GITHUB_SHA} > ${ARTIFACT_FILE}/build.txt
cp -R vendor ${ARTIFACT_FILE}/
mkdir -p ${ARTIFACT_FILE}/public/dist && cp -R public/dist/. ${ARTIFACT_FILE}/public/dist
find ./${ARTIFACT_FILE} -type d | xargs chmod 755
find ./${ARTIFACT_FILE} -name '*.php' | xargs chmod 644
zip -r -9 ${ARTIFACT_FILENAME} ${ARTIFACT_FILE}
curl -LO https://raw.githubusercontent.com/bmlt-enabled/release-notes-tool/master/gh-release-notes.sh
chmod +x gh-release-notes.sh
./gh-release-notes.sh RELEASENOTES.md "###"
- name: Prepare artifact metadata
id: prepare_artifact_metadata
run: |
echo ::set-output name=ARTIFACT_PATH::./yap-${GITHUB_REF##*/}.zip
echo ::set-output name=ARTIFACT_NAME::yap-${GITHUB_REF##*/}.zip
- name: Upload Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ${{ steps.prepare_artifact_metadata.outputs.ARTIFACT_PATH }}
asset_name: ${{ steps.prepare_artifact_metadata.outputs.ARTIFACT_NAME }}
asset_content_type: application/zip
- uses: act10ns/slack@v1
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: '#yap'
if: failure()