-
Notifications
You must be signed in to change notification settings - Fork 2
127 lines (106 loc) · 4.11 KB
/
php.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
name: PHP
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Fetch all history for all tags and branches
run: git fetch --prune --unshallow
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '5.x'
- name: Execute GitVersion
id: gitversion # step id used as reference for output values
uses: gittools/actions/gitversion/[email protected]
- name: PHP Setup
uses: shivammathur/setup-php@v2
with:
php-version: '7.2'
- name: Version variables for unstable builds
id: unstable
if: startsWith(github.ref, 'refs/tags/') != true
env:
LABEL: "-dev${{ steps.gitversion.outputs.commitsSinceVersionSourcePadded }}"
run: |
echo "Pre-release: ${LABEL}"
echo "##[set-output name=label;]${LABEL}"
- name: Version stamp composer.json
env:
COMPOSER_VERSION: "${{ steps.gitversion.outputs.majorMinorPatch }}${{ steps.unstable.outputs.label }}"
run: |
echo "Composer version: ${COMPOSER_VERSION}"
jq ".version=\"${COMPOSER_VERSION}\"" composer.json > composer.version.json # Add "version" property to composer.version.json
mv composer.json composer.clean.json
mv composer.version.json composer.json # Rename composer.version.json to composer.json
- name: Create ZIP archive
id: archive
env:
SEMVER: ${{ steps.gitversion.outputs.fullSemVer }}
run: |
ARCHIVE=${GITHUB_REPOSITORY#SwedbankPay/}-${SEMVER}.zip
echo "Archive: ${ARCHIVE}"
echo "::set-output name=name::${ARCHIVE}"
zip --recurse-paths --exclude="*.zip" --exclude="vendor/*" --exclude="composer.clean.json" ${ARCHIVE} *
unzip -l ${ARCHIVE}
rm composer.json
mv composer.clean.json composer.json # Move the version-less composer.json back in place so `composer validate` won't react on it in the script section.
- name: Upload artifact
uses: actions/upload-artifact@v2-preview
with:
name: ${{ steps.archive.outputs.name }}
path: ${{ steps.archive.outputs.name }}
- name: Validate M2 Package
run: php ./vendor/validate_m2_package.php -d ${{ steps.archive.outputs.name }}
- name: Validate composer.json and composer.lock
run: composer validate
- name: Add auth.json
run: |
cat << EOF > auth.json
{
"http-basic": {
"repo.magento.com": {
"username": "${{ secrets.MAGENTO_PUBLIC_KEY }}",
"password": "${{ secrets.MAGENTO_PRIVATE_KEY }}"
}
}
}
EOF
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest
- name: Get Composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/[email protected]
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: PHPCS Check
run: ./vendor/bin/phpcs --standard=Magento2 --report=code --ignore=vendor,view --runtime-set ignore_warnings_on_exit true .
- name: PHPUnit
run: ./vendor/bin/phpunit ./Test/Unit
- name: Pre-release
uses: marvinpinto/action-automatic-releases@latest
if: startsWith(github.ref, 'refs/heads/master')
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
automatic_release_tag: latest
prerelease: true
title: Development Build
files: ${{ steps.archive.outputs.name }}
- name: Upload to stable release
uses: svenstaro/upload-release-action@v1-release
if: startsWith(github.ref, 'refs/tags/')
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ steps.archive.outputs.name }}
asset_name: ${{ steps.archive.outputs.name }}
tag: ${{ github.ref }}
overwrite: true