-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (83 loc) · 3.77 KB
/
Copy pathbuild-phar.yaml
File metadata and controls
95 lines (83 loc) · 3.77 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
name: Build Shopsys CLI PHAR
on:
push:
branches:
- '[0-9]+.[0-9]+'
tags:
- 'v*'
workflow_dispatch:
inputs:
release_tag:
description: 'Release tag name (e.g., v1.0.0)'
required: true
type: string
jobs:
build:
name: Build PHAR
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.5'
tools: composer
extensions: json, yaml
- name: Install dependencies
run: composer install --no-dev --optimize-autoloader --prefer-dist
- name: Install Box
run: composer global require humbug/box
- name: Determine release tag
id: release_tag
run: |
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref_type }}" == "tag" ]]; then
# Version tag (v*) - proper release
echo "tag=${{ github.ref_name }}" >> $GITHUB_OUTPUT
echo "is_prerelease=false" >> $GITHUB_OUTPUT
echo "replace_existing=false" >> $GITHUB_OUTPUT
elif [[ -n "$INPUT_TAG" ]]; then
# Manual dispatch with specific tag - always replaceable
echo "tag=$INPUT_TAG" >> $GITHUB_OUTPUT
echo "is_prerelease=false" >> $GITHUB_OUTPUT
echo "replace_existing=true" >> $GITHUB_OUTPUT
else
# Version branch (e.g., 19.0, 17.1) - replaceable release
echo "tag=${{ github.ref_name }}" >> $GITHUB_OUTPUT
echo "is_prerelease=true" >> $GITHUB_OUTPUT
echo "replace_existing=true" >> $GITHUB_OUTPUT
fi
env:
INPUT_TAG: ${{ inputs.release_tag }}
- name: Add build metadata
run: |
echo "BUILD_SHA=${{ github.sha }}" >> .build-metadata
echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> .build-metadata
echo "BUILD_REF=${{ steps.release_tag.outputs.tag }}" >> .build-metadata
- name: Set CLI version in box.json
run: sed -i 's/\$CLI_VERSION/${{ steps.release_tag.outputs.tag }}/' box.json
- name: Build PHAR
run: box compile
- name: Test PHAR
run: |
php shopsys.phar --version
php shopsys.phar workers
- name: Delete existing release
if: steps.release_tag.outputs.replace_existing == 'true'
run: gh release delete "$RELEASE_TAG" --cleanup-tag --yes || true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: ${{ steps.release_tag.outputs.tag }}
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: shopsys.phar
tag_name: ${{ steps.release_tag.outputs.tag }}
target_commitish: ${{ github.sha }}
name: ${{ steps.release_tag.outputs.tag }}
prerelease: ${{ steps.release_tag.outputs.is_prerelease == 'true' }}
generate_release_notes: ${{ steps.release_tag.outputs.replace_existing != 'true' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}