-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (70 loc) · 2.32 KB
/
Copy pathrelease.yml
File metadata and controls
80 lines (70 loc) · 2.32 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
name: Release WP-SSO
on:
workflow_dispatch:
inputs:
version:
description: 'Release version without the v prefix (for example 1.2.0)'
required: true
default: '1.1.0'
permissions:
contents: write
jobs:
release:
name: Build and publish release
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Resolve version
id: version
shell: bash
run: |
VERSION="${{ inputs.version }}"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "tag=v$VERSION" >> "$GITHUB_OUTPUT"
- name: Validate plugin version
shell: bash
run: |
VERSION="${{ steps.version.outputs.version }}"
grep -q "Version: $VERSION" wp-sso/wp-sso.php
grep -q "const VERSION = '$VERSION'" wp-sso/wp-sso.php
grep -q "Stable tag: $VERSION" wp-sso/readme.txt
- name: Validate PHP syntax
run: php -l wp-sso/wp-sso.php
- name: Build release assets
shell: bash
run: |
mkdir -p build
zip -r build/wp-sso.zip wp-sso -x '*.DS_Store'
cp 'WordPress SSO.xml' build/WordPress-SSO-IPS.xml
- name: Create tag when missing
shell: bash
run: |
TAG="${{ steps.version.outputs.tag }}"
if git ls-remote --exit-code --tags origin "refs/tags/$TAG" >/dev/null 2>&1; then
echo "Tag $TAG already exists."
else
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag -a "$TAG" -m "WP-SSO $TAG"
git push origin "$TAG"
fi
- name: Publish GitHub Release
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
TAG="${{ steps.version.outputs.tag }}"
TITLE="WP-SSO $TAG"
if gh release view "$TAG" >/dev/null 2>&1; then
gh release upload "$TAG" build/wp-sso.zip build/WordPress-SSO-IPS.xml --clobber
else
gh release create "$TAG" \
build/wp-sso.zip \
build/WordPress-SSO-IPS.xml \
--title "$TITLE" \
--generate-notes \
--verify-tag
fi