-
-
Notifications
You must be signed in to change notification settings - Fork 155
201 lines (176 loc) · 6.78 KB
/
ci.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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
name: ci
on:
push:
branches:
- "*"
tags:
- "*"
pull_request:
branches:
- "*"
jobs:
test:
runs-on: ${{ matrix.operating-system }}
continue-on-error: ${{ matrix.allow-failure }}
strategy:
max-parallel: 15
matrix:
operating-system: [ubuntu-22.04, macos-12]
php-version: ["8.1", "8.2"]
allow-failure: [false]
include:
- php-version: 8.3
operating-system: ubuntu-22.04
allow-failure: true
- php-version: 8.3
operating-system: macos-12
allow-failure: true
- php-version: 8.3
operating-system: macos-13
allow-failure: true
name: Test PHP ${{ matrix.php-version }} on ${{ matrix.operating-system }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@master
with:
php-version: ${{ matrix.php-version }}
extensions: apcu, mbstring, pcov
ini-values: apc.enabled=1, apc.enable_cli=1, opcache.enable=1, opcache.enable_cli=1, opcache.jit=disable
coverage: pcov
- name: Check PHP Version
run: php -v
- name: Check Composer Version
run: composer -V
- name: Check PHP Extensions
run: php -m
- name: Get Composer Cache Directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json') }}
restore-keys: ${{ runner.os }}-composer-${{ hashFiles('composer.json') }}
- name: Install Dependencies
if: ${{ !matrix.allow-failure }}
run: composer install --prefer-dist
- name: Install Dependencies (ignoring platform requirements)
if: ${{ matrix.allow-failure }}
run: composer install --prefer-dist --ignore-platform-req=php+
- name: Run test suite
run: $(composer config bin-dir)/phpunit --coverage-clover=coverage.clover
- name: Upload coverage to coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.4.3/php-coveralls.phar
php php-coveralls.phar --coverage_clover=coverage.clover --json_path=coveralls-upload.json -v
release:
runs-on: ubuntu-22.04
name: Create & Publish Release
if: ${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') }}
needs: test
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get tag & commit hash
id: info
run: |
echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT
echo "COMMIT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: cachetool
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Setup PHP
uses: shivammathur/setup-php@master
with:
php-version: 8.2
- name: Install Dependencies
run: |
composer global config minimum-stability dev
composer global config prefer-stable true
composer global require humbug/box
composer install --prefer-dist --no-dev
- name: Create Release Assets
run: |
jq '. + {compression: "GZ", output: "cachetool.phar.gz"}' box.json > box.gz.json
jq '. + {compression: "BZ2", output: "cachetool.phar.bz2"}' box.json > box.bz2.json
$(composer config home)/vendor/bin/box compile --config=box.json
$(composer config home)/vendor/bin/box compile --config=box.gz.json
$(composer config home)/vendor/bin/box compile --config=box.bz2.json
- name: Build & tag images (${{ steps.info.outputs.VERSION }} and latest)
if: ${{ !contains(github.ref, '-') }}
uses: docker/build-push-action@v3
with:
build-args: |
BUILD_DATE=${{ steps.info.outputs.BUILD_DATE }}
CACHETOOL_VERSION=${{ steps.info.outputs.VERSION }}
COMMIT_SHA=${{ steps.info.outputs.COMMIT_SHA }}
PHP_VERSION=8.1
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
gordalina/cachetool:latest
gordalina/cachetool:${{ steps.info.outputs.VERSION }}
ghcr.io/gordalina/cachetool:latest
ghcr.io/gordalina/cachetool:${{ steps.info.outputs.VERSION }}
- name: Build & tag images (${{ steps.info.outputs.VERSION }})
if: ${{ contains(github.ref, '-') }}
uses: docker/build-push-action@v3
with:
build-args: |
BUILD_DATE=${{ steps.info.outputs.BUILD_DATE }}
CACHETOOL_VERSION=${{ steps.info.outputs.VERSION }}
COMMIT_SHA=${{ steps.info.outputs.COMMIT_SHA }}
PHP_VERSION=8.1
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
gordalina/cachetool:${{ steps.info.outputs.VERSION }}
ghcr.io/gordalina/cachetool:${{ steps.info.outputs.VERSION }}
- name: Create GitHub Release
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: ${{ steps.info.outputs.VERSION }}
tag_name: ${{ steps.info.outputs.VERSION }}
draft: false
prerelease: ${{ contains(github.ref, '-') }}
files: |
cachetool.phar
cachetool.phar.gz
cachetool.phar.bz2
CHANGELOG.md
LICENSE
body: |
## Changelog
The full changelog can be found in our [changelog file](https://github.com/gordalina/cachetool/blob/${{ steps.info.outputs.VERSION }}/CHANGELOG.md)
- name: Update GitHub Pages
if: ${{ !contains(github.ref, '-') }}
run: |
REF="${{ github.ref }}"
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"
bin/update-gh-pages.sh ${{ steps.info.outputs.VERSION }}