-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (99 loc) · 4.14 KB
/
Copy pathrelease-phpstorm-plugin.yml
File metadata and controls
109 lines (99 loc) · 4.14 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
name: PhpStorm Plugin Release
on:
push:
tags:
- 'v*'
permissions:
# Required to create the Release and upload assets to it. Read-only
# checkout would otherwise fail when softprops/action-gh-release tries
# to POST to the releases API.
contents: write
# Don't cancel a release mid-upload -- a half-uploaded asset is worse
# than a duplicate run. Concurrency group keys on the tag, so two tags
# released back-to-back don't collide.
concurrency:
group: release-phpstorm-plugin-${{ github.event.inputs.tag || github.ref_name }}
cancel-in-progress: false
jobs:
release:
name: Build + publish PhpStorm plugin
runs-on: ubuntu-latest
steps:
- name: Resolve tag + version
id: tag
# On a push:tags trigger, GITHUB_REF is `refs/tags/v0.1.0`.
# On workflow_dispatch, the user-supplied input takes over.
# `version` is the tag minus the leading `v` so it threads
# straight into Gradle's pluginVersion (which has no v prefix).
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
tag="${{ github.event.inputs.tag }}"
else
tag="${GITHUB_REF#refs/tags/}"
fi
if [[ ! "$tag" =~ ^v[0-9] ]]; then
echo "::error::tag '$tag' must start with 'v' followed by a digit (e.g. v0.1.0)"
exit 1
fi
version="${tag#v}"
echo "tag=$tag" >> "$GITHUB_OUTPUT"
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Checkout at tag
uses: actions/checkout@v4
with:
ref: ${{ steps.tag.outputs.tag }}
fetch-depth: 1
- name: Setup JDK 21
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '21'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Build plugin zip with tag-derived version
# -PpluginVersion overrides the gradle.properties default, so:
# - the produced zip is xphp-phpstorm-plugin-<version>.zip
# - plugin.xml's <version> matches the git tag
# - the JetBrains Marketplace update channel (if ever published)
# reads the tag-driven version, not a stale 0.1.0
#
# downloadLspPhar fetches the xphp LSP binary from `xphpLspPharUrl` in
# gradle.properties and bundles it at bin/xphp-lsp.phar. buildPlugin
# FAILS if that property is unset/empty -- a release zip never ships
# without an embedded LSP.
run: |
./gradlew \
buildPlugin \
-PpluginVersion=${{ steps.tag.outputs.version }}
- name: Locate built zip
id: zip
# `ls` produces a single match because Gradle emits exactly one
# zip per buildPlugin run. Fail loudly if the path doesn't
# match what we expected -- catches a Gradle config drift early.
run: |
path=$(ls build/distributions/xphp-phpstorm-plugin-${{ steps.tag.outputs.version }}.zip)
if [[ ! -f "$path" ]]; then
echo "::error::zip not found at expected path"
ls -la build/distributions/ || true
exit 1
fi
echo "path=$path" >> "$GITHUB_OUTPUT"
echo "name=$(basename "$path")" >> "$GITHUB_OUTPUT"
- name: Create release and upload zip
# softprops/action-gh-release creates the GitHub Release if it
# doesn't exist yet (push:tags case) and updates it idempotently
# on workflow_dispatch re-runs. `files:` uploads the zip as a
# release asset -- the resulting download URL is:
# https://github.com/<owner>/<repo>/releases/download/<tag>/<asset>
# i.e. the tag appears in the URL path AND inside the asset
# filename (`...-<version>.zip`), so the version is impossible
# to miss from either direction.
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.tag.outputs.tag }}
name: ${{ steps.tag.outputs.tag }}
draft: false
prerelease: false
files: ${{ steps.zip.outputs.path }}
generate_release_notes: true
fail_on_unmatched_files: true