Skip to content

Commit 0ca9e9e

Browse files
authored
Release Workflow
1 parent 6bcaea4 commit 0ca9e9e

1 file changed

Lines changed: 79 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Create Release
2+
3+
on:
4+
push:
5+
# Trigger on pushes to main or master branch
6+
branches: [ main, master ]
7+
# Allow manual triggering
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: write
12+
discussions: write
13+
14+
jobs:
15+
check-and-release:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v3
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Get latest version
24+
id: get_version
25+
run: |
26+
VERSION=$(grep -oP "Version: \K[0-9]+\.[0-9]+\.[0-9]+" simple-site-exporter.php)
27+
echo "version=$VERSION" >> $GITHUB_OUTPUT
28+
echo "Found version: $VERSION"
29+
30+
- name: Check if release exists
31+
id: check_release
32+
run: |
33+
RELEASE_EXISTS=$(curl -s -o /dev/null -w "%{http_code}" https://api.github.com/repos/${{ github.repository }}/releases/tags/v${{ steps.get_version.outputs.version }})
34+
if [[ "$RELEASE_EXISTS" == "200" ]]; then
35+
echo "exists=true" >> $GITHUB_OUTPUT
36+
echo "Release v${{ steps.get_version.outputs.version }} already exists"
37+
else
38+
echo "exists=false" >> $GITHUB_OUTPUT
39+
echo "Release v${{ steps.get_version.outputs.version }} does not exist yet"
40+
fi
41+
42+
- name: Create zip file
43+
if: steps.check_release.outputs.exists == 'false'
44+
run: |
45+
mkdir -p enginescript-simple-site-exporter
46+
cp simple-site-exporter.php enginescript-simple-site-exporter/
47+
cp README.md enginescript-simple-site-exporter/
48+
cp CHANGELOG.md enginescript-simple-site-exporter/
49+
cp LICENSE enginescript-simple-site-exporter/ || echo "No LICENSE file found"
50+
zip -r enginescript-simple-site-exporter-${{ steps.get_version.outputs.version }}.zip enginescript-simple-site-exporter
51+
52+
- name: Get changelog entry
53+
if: steps.check_release.outputs.exists == 'false'
54+
id: get_changelog
55+
run: |
56+
CHANGELOG_ENTRY=$(awk -v ver="## ${{ steps.get_version.outputs.version }}" 'BEGIN{flag=0} $0~ver{flag=1; print; next} /^## [0-9]+\.[0-9]+\.[0-9]+/{flag=0} flag{print}' CHANGELOG.md | tail -n +2)
57+
echo "changelog<<EOF" >> $GITHUB_OUTPUT
58+
echo "$CHANGELOG_ENTRY" >> $GITHUB_OUTPUT
59+
echo "EOF" >> $GITHUB_OUTPUT
60+
61+
- name: Create Release
62+
if: steps.check_release.outputs.exists == 'false'
63+
uses: softprops/action-gh-release@v1
64+
with:
65+
tag_name: v${{ steps.get_version.outputs.version }}
66+
name: Release v${{ steps.get_version.outputs.version }}
67+
body: |
68+
${{ steps.get_changelog.outputs.changelog }}
69+
70+
## Installation
71+
1. Download the zip file
72+
2. Upload to your WordPress site through the Plugins > Add New > Upload menu
73+
3. Activate the plugin
74+
75+
[Full Documentation](https://github.com/${{ github.repository }})
76+
files: enginescript-simple-site-exporter-${{ steps.get_version.outputs.version }}.zip
77+
draft: false
78+
prerelease: false
79+
generate_release_notes: false

0 commit comments

Comments
 (0)