-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (76 loc) · 2.83 KB
/
release.yml
File metadata and controls
89 lines (76 loc) · 2.83 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
name: Create Release
on:
push:
tags:
- 'v*'
- '[0-9]+.*'
permissions:
contents: write
jobs:
release:
name: Create GitHub Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get tag name
id: tag
run: |
echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
coverage: none
- name: Install Composer dependencies
run: composer install --no-dev --optimize-autoloader --prefer-dist
- name: Create distribution package
run: |
mkdir -p dist
rsync -av --exclude-from='.distignore' . dist/wp-github-updater/
cd dist
zip -r wp-github-updater-${{ steps.tag.outputs.version }}.zip wp-github-updater/
- name: Generate changelog
id: changelog
run: |
# Get the previous tag
PREV_TAG=$(git describe --tags --abbrev=0 ${{ steps.tag.outputs.tag }}^ 2>/dev/null || echo "")
if [ -z "$PREV_TAG" ]; then
# First release
CHANGELOG=$(git log --pretty=format:"- %s (%h)" ${{ steps.tag.outputs.tag }})
else
# Generate changelog between tags
CHANGELOG=$(git log --pretty=format:"- %s (%h)" $PREV_TAG..${{ steps.tag.outputs.tag }})
fi
# Save changelog to file
echo "## Changes" > changelog.md
echo "" >> changelog.md
echo "$CHANGELOG" >> changelog.md
echo "" >> changelog.md
echo "---" >> changelog.md
echo "" >> changelog.md
echo "📦 **Installation:** Download the \`wp-github-updater-${{ steps.tag.outputs.version }}.zip\` file" >> changelog.md
echo "" >> changelog.md
echo "📚 **Full Changelog:** https://github.com/${{ github.repository }}/compare/$PREV_TAG...${{ steps.tag.outputs.tag }}" >> changelog.md
- name: Create Release
uses: softprops/action-gh-release@v1
with:
name: Release ${{ steps.tag.outputs.tag }}
body_path: changelog.md
files: |
dist/wp-github-updater-${{ steps.tag.outputs.version }}.zip
draft: false
prerelease: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: wp-github-updater-${{ steps.tag.outputs.version }}
path: dist/wp-github-updater-${{ steps.tag.outputs.version }}.zip
retention-days: 30