-
Notifications
You must be signed in to change notification settings - Fork 0
150 lines (125 loc) Β· 4.65 KB
/
Copy pathrelease.yml
File metadata and controls
150 lines (125 loc) Β· 4.65 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
name: Release
on:
push:
tags:
- '[0-9]+\.[0-9]+\.[0-9]+'
- '[0-9]+\.[0-9]+\.[0-9]+-*'
env:
PLUGIN_SLUG: wp-secure-plugin-updates
PLUGIN_NAME: WP Secure Plugin Updates
jobs:
build:
name: Build Release Package
runs-on: ubuntu-latest
outputs:
version: ${{ steps.info.outputs.version }}
is_prerelease: ${{ steps.info.outputs.is_prerelease }}
zip_name: ${{ steps.package.outputs.name }}
changelog_content: ${{ steps.changelog.outputs.content }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Extract release information
id: info
env:
TAG: ${{ github.ref_name }}
run: |
VERSION="${TAG}"
IS_PRERELEASE="false"
if [[ "$VERSION" =~ -(alpha|beta|rc) ]]; then
IS_PRERELEASE="true"
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "is_prerelease=${IS_PRERELEASE}" >> $GITHUB_OUTPUT
echo "π¦ Plugin: ${{ env.PLUGIN_NAME }}"
echo "π·οΈ Version: ${VERSION}"
echo "π Pre-release: ${IS_PRERELEASE}"
- name: Extract changelog
id: changelog
env:
VERSION: ${{ steps.info.outputs.version }}
run: |
CHANGELOG=""
if [ -f "CHANGELOG.md" ]; then
CHANGELOG=$(sed -n "/^## \[*v*${VERSION}[]\) -]*/,/^## /p" CHANGELOG.md | sed '1d;$d' | awk 'NF {p=1} p')
fi
if [ -z "$CHANGELOG" ]; then
CHANGELOG="Release ${VERSION}"
fi
{
echo 'content<<EOF'
echo "$CHANGELOG"
echo 'EOF'
} >> $GITHUB_OUTPUT
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm install --loglevel=error
- name: Create release package
id: package
env:
VERSION: ${{ steps.info.outputs.version }}
run: |
ZIP_NAME="${{ env.PLUGIN_SLUG }}_${VERSION}.zip"
npm run release -- --zip-name "${ZIP_NAME}"
if [ ! -f "${ZIP_NAME}" ]; then
echo "β Package not found: ${ZIP_NAME}"
exit 1
fi
FILE_SIZE=$(ls -lh "${ZIP_NAME}" | awk '{print $5}')
echo "β
Package created: ${ZIP_NAME} (${FILE_SIZE})"
echo "name=${ZIP_NAME}" >> $GITHUB_OUTPUT
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.PLUGIN_SLUG }}-${{ steps.info.outputs.version }}
path: ${{ steps.package.outputs.name }}
retention-days: 30
github-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: build
permissions:
contents: write
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: ${{ env.PLUGIN_SLUG }}-${{ needs.build.outputs.version }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: ${{ env.PLUGIN_NAME }} ${{ needs.build.outputs.version }}
body: ${{ needs.build.outputs.changelog_content }}
files: ${{ needs.build.outputs.zip_name }}
prerelease: ${{ needs.build.outputs.is_prerelease == 'true' }}
summary:
name: Release Summary
runs-on: ubuntu-latest
needs: [build, github-release]
if: always()
steps:
- name: Generate summary
env:
VERSION: ${{ needs.build.outputs.version }}
IS_PRERELEASE: ${{ needs.build.outputs.is_prerelease }}
BUILD_RESULT: ${{ needs.build.result }}
GH_RESULT: ${{ needs.github-release.result }}
REPO: ${{ github.repository }}
run: |
TYPE="π Stable"
[ "$IS_PRERELEASE" == "true" ] && TYPE="πΆ Pre-release"
echo "# Release Summary: ${{ env.PLUGIN_NAME }} ${VERSION}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Type:** ${TYPE}" >> $GITHUB_STEP_SUMMARY
echo "**Release:** https://github.com/${REPO}/releases/tag/${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "## Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
[ "$BUILD_RESULT" == "success" ] && echo "β
**Build**: Package created" >> $GITHUB_STEP_SUMMARY || echo "β **Build**: Failed" >> $GITHUB_STEP_SUMMARY
[ "$GH_RESULT" == "success" ] && echo "β
**GitHub Release**: Created" >> $GITHUB_STEP_SUMMARY || echo "β **GitHub Release**: Failed" >> $GITHUB_STEP_SUMMARY