-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
159 lines (137 loc) · 5.2 KB
/
action.yml
File metadata and controls
159 lines (137 loc) · 5.2 KB
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
name: PHP Matrix
description: Generate PHP version matrix according to `composer.json`
author: Typist Tech Limited
branding:
icon: grid
color: black
inputs:
composer-json:
description: Path to composer.json
default: composer.json
mode:
description: Version format
default: minor-only
source:
description: Source of releases information
default: auto
version:
description: |
The version of php-matrix to use. Leave blank for latest. For example: v1.0.2
default: ''
verify-attestation:
description: Whether to verify PHP matrix tarball attestation
default: true
github-token:
description: GitHub token to use for authentication
default: ${{ github.token }}
outputs:
constraint:
description: The `require.php` constraint found in `composer.json`
value: ${{ fromJSON(steps.generate-matrix.outputs.matrix).constraint }}
highest:
description: Highest supported PHP versions
value: ${{ fromJSON(steps.generate-matrix.outputs.matrix).highest }}
lowest:
description: Lowest supported PHP versions
value: ${{ fromJSON(steps.generate-matrix.outputs.matrix).lowest }}
versions:
description: Array of all supported PHP versions
value: ${{ toJSON(fromJSON(steps.generate-matrix.outputs.matrix).versions) }}
runs:
using: "composite"
steps:
- name: Download PHP Matrix (Linux arm64)
if: ${{ runner.os == 'Linux' && runner.arch == 'ARM64' }}
run: gh release download --repo typisttech/php-matrix --output php-matrix.tar.gz --pattern "${PATTERN}" "${TAG}"
shell: bash
working-directory: ${{ github.action_path }}
env:
PATTERN: php-matrix_linux_arm64.tar.gz
TAG: ${{ inputs.version }}
GH_TOKEN: ${{ inputs.github-token }}
- name: Download PHP Matrix (Linux amd64)
if: ${{ runner.os == 'Linux' && runner.arch == 'x64' }}
run: gh release download --repo typisttech/php-matrix --output php-matrix.tar.gz --pattern "${PATTERN}" "${TAG}"
shell: bash
working-directory: ${{ github.action_path }}
env:
PATTERN: php-matrix_linux_amd64.tar.gz
TAG: ${{ inputs.version }}
GH_TOKEN: ${{ github.token }}
- name: Download PHP Matrix (Darwin arm64)
if: ${{ runner.os == 'macOS' && runner.arch == 'ARM64' }}
run: gh release download --repo typisttech/php-matrix --output php-matrix.tar.gz --pattern "${PATTERN}" "${TAG}"
shell: bash
working-directory: ${{ github.action_path }}
env:
PATTERN: php-matrix_darwin_arm64.tar.gz
TAG: ${{ inputs.version }}
GH_TOKEN: ${{ inputs.github-token }}
- name: Download PHP Matrix (Darwin amd64)
if: ${{ runner.os == 'macOS' && runner.arch == 'x64' }}
run: gh release download --repo typisttech/php-matrix --output php-matrix.tar.gz --pattern "${PATTERN}" "${TAG}"
shell: bash
working-directory: ${{ github.action_path }}
env:
PATTERN: php-matrix_darwin_amd64.tar.gz
TAG: ${{ inputs.version }}
GH_TOKEN: ${{ inputs.github-token }}
- name: Verify Attestation
if: ${{ inputs.verify-attestation == 'true' }}
run: gh attestation verify --repo typisttech/php-matrix php-matrix.tar.gz
shell: bash
working-directory: ${{ github.action_path }}
env:
GH_TOKEN: ${{ inputs.github-token }}
- name: Unarchive the Binary
run: |
mkdir bin
tar -xvf php-matrix.tar.gz -C ./bin php-matrix
shell: bash
working-directory: ${{ github.action_path }}
- name: Add the binary into PATH
run: echo "${ACTION_PATH}/bin" >> "$GITHUB_PATH"
shell: bash
env:
ACTION_PATH: ${{ github.action_path }}
- name: Generate Matrix
id: generate-matrix
run: |
php-matrix composer --mode="${INPUT_MODE}" --source="${INPUT_SOURCE}" "${INPUT_COMPOSER_JSON}" > matrix 2>&1
retVal=$?
if [ $retVal -ne 0 ]; then
echo "::error::Unable to generate matrix"
exit 1
fi
{
echo 'matrix<<EOF'
cat matrix
echo EOF
} >> "$GITHUB_OUTPUT"
shell: sh
env:
INPUT_COMPOSER_JSON: ${{ inputs.composer-json }}
INPUT_MODE: ${{ inputs.mode }}
INPUT_SOURCE: ${{ inputs.source }}
- name: Print Info
if: ${{ !cancelled() }}
run: |
echo "==> Setup PHP Matrix"
echo -e "\033[32;m✓\033[0m \033[34;mphp-matrix\033[0m https://github.com/typisttech/php-matrix"
echo "::group::$ php-matrix --version"
php-matrix --version
echo "::endgroup::"
echo ""
echo "==> Sponsor php-matrix-action"
echo -e "\033[32;m✓\033[0m \033[34;mphp-matrix-action\033[0m https://github.com/sponsors/tangrufus"
echo ""
echo "==> Hire Tang Rufus"
echo "I am looking for my next role, freelance or full-time."
echo "If you find this tool useful, I can build you more dev tools like this."
echo "Let's talk if you are hiring PHP / Ruby / Go developers."
echo -e "\033[32;m✓\033[0m \033[34;mTang Rufus\033[0m https://typist.tech/contact"
echo ""
echo "::group::==> Matrix Output"
cat matrix
echo "::endgroup::"
shell: bash