Skip to content

Commit f9e9502

Browse files
authored
Merge pull request #21 from codeboxrcodehub/dev
Version 1.0.9 released
2 parents c198b1f + 93c1265 commit f9e9502

File tree

1 file changed

+72
-64
lines changed

1 file changed

+72
-64
lines changed

.github/workflows/deploy.yml

Lines changed: 72 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -3,79 +3,87 @@ name: Create Release
33
on:
44
push:
55
tags:
6-
- '*.*.*' # Triggers on tags like 1.0.0
6+
- '*.*.*'
77
branches:
8-
- master # Ensures it only runs on the master branch
8+
- master
99

1010
jobs:
1111
create_release:
12-
if: github.ref == 'refs/heads/master' # Ensures the job runs only on master branch
12+
if: github.ref == 'refs/heads/master'
1313
runs-on: ubuntu-latest
14-
1514
steps:
16-
- name: Checkout repository
17-
uses: actions/checkout@v2
18-
with:
19-
fetch-depth: 0 # Fetch all history for all tags
15+
- uses: actions/checkout@v3 # Use v3 for better performance and security
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Read version from readme.txt
20+
id: read_version
21+
run: |
22+
VERSION=$(grep -oP 'Stable tag: \K[0-9.]+' readme.txt) # Use \K to only capture the version
23+
echo "plugin_version=$VERSION" >> $GITHUB_ENV
24+
25+
- name: Get latest tag
26+
id: get_latest_tag
27+
run: |
28+
git fetch --tags
29+
LATEST_TAG=$(git describe --tags --abbrev=0) # --abbrev=0 to get full tag name
30+
if [[ -z "$LATEST_TAG" ]]; then
31+
echo "No tags found"
32+
exit 1
33+
fi
34+
echo "latest_tag=$LATEST_TAG" >> $GITHUB_ENV
35+
36+
- name: Extract Changelog
37+
id: extract_changelog
38+
run: |
39+
START=$(grep -n "== Changelog ==" readme.txt | cut -d: -f1)
40+
if [[ -z "$START" ]]; then
41+
echo "::error::Changelog section not found."
42+
exit 1
43+
fi
44+
START=$((START + 1)) # Start from the line after "== Changelog =="
2045
21-
- name: Read version from readme.txt
22-
id: read_version
23-
run: |
24-
VERSION=$(grep -Eo 'Stable tag: [0-9]+\.[0-9]+\.[0-9]+' readme.txt | awk '{print $3}')
25-
echo "plugin_version=$VERSION" >> $GITHUB_ENV
46+
# Extract changelog until the next top-level heading or end of file
47+
END=$(grep -n -m 1 -E "^==|^$" readme.txt | tail -n 1 | cut -d: -f1) # find next heading or EOF
48+
if [[ -z "$END" ]]; then
49+
END=$(wc -l < readme.txt) # If no next heading, use EOF
50+
fi
51+
END=$((END - 1)) # End one line before the next heading
2652
27-
- name: Get latest tag
28-
id: get_latest_tag
29-
run: |
30-
git fetch --tags # Ensure all tags are fetched
31-
LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`)
32-
if [ -z "$LATEST_TAG" ]; then
33-
echo "No tags found"
34-
exit 1
35-
fi
36-
echo "latest_tag=$LATEST_TAG" >> $GITHUB_ENV
53+
if [[ $START -gt $END ]]; then # Handle cases where there is no changelog content
54+
echo "::warning::No changelog content found."
55+
echo "" > CHANGELOG.txt # create empty file
56+
else
57+
sed -n "${START},${END}p" readme.txt > CHANGELOG.txt
58+
fi
3759
38-
- name: Extract Changelog
39-
id: extract_changelog
40-
run: |
41-
START_LINE=$(grep -n "== Changelog ==" readme.txt | cut -d : -f 1)
42-
END_LINE=$(grep -n "= ${{ env.plugin_version }} =" readme.txt | cut -d : -f 1)
43-
if [ -z "$START_LINE" ] || [ -z "$END_LINE" ]; then
44-
echo "Changelog not found"
45-
exit 1
46-
fi
47-
sed -n "${START_LINE},${END_LINE}p" readme.txt | sed '1d;$d' > CHANGELOG.txt
48-
CHANGELOG_CONTENT=$(cat CHANGELOG.txt)
49-
if [ -z "$CHANGELOG_CONTENT" ]; then
50-
echo "Changelog content is empty"
51-
exit 1
52-
fi
53-
echo "changelog=$CHANGELOG_CONTENT" >> $GITHUB_ENV
60+
CHANGELOG_CONTENT=$(cat CHANGELOG.txt)
61+
echo "changelog=$CHANGELOG_CONTENT" >> $GITHUB_ENV
5462
55-
- name: Create zip file
56-
run: |
57-
REPO_NAME=$(basename `git rev-parse --show-toplevel`)
58-
zip -r ${REPO_NAME}.zip . -x '*.git*' -x '*.github*' -x '*.distignore*' -x 'CHANGELOG.txt'
59-
echo "repo_name=${REPO_NAME}" >> $GITHUB_ENV
63+
- name: Create zip file
64+
run: |
65+
REPO_NAME=$(basename `git rev-parse --show-toplevel`)
66+
zip -r ${REPO_NAME}.zip . -x '*.git*' -x '.github/*' -x '*.distignore*' -x 'CHANGELOG.txt'
67+
echo "repo_name=${REPO_NAME}" >> $GITHUB_ENV
6068
61-
- name: Create Release
62-
id: create_release
63-
uses: actions/create-release@v1
64-
env:
65-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66-
with:
67-
tag_name: ${{ env.latest_tag }}
68-
release_name: "Release ${{ env.plugin_version }}"
69-
body: ${{ env.changelog }}
70-
draft: false
71-
prerelease: false
69+
- name: Create Release
70+
id: create_release
71+
uses: actions/create-release@v1
72+
env:
73+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
74+
with:
75+
tag_name: ${{ env.latest_tag }}
76+
release_name: "Release ${{ env.plugin_version }}"
77+
body: ${{ env.changelog }}
78+
draft: false
79+
prerelease: false
7280

73-
- name: Upload Release Asset
74-
uses: actions/upload-release-asset@v1
75-
env:
76-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77-
with:
78-
upload_url: ${{ steps.create_release.outputs.upload_url }}
79-
asset_path: ./${{ env.repo_name }}.zip
80-
asset_name: ${{ env.repo_name }}.zip
81-
asset_content_type: application/zip
81+
- name: Upload Release Asset
82+
uses: actions/upload-release-asset@v1
83+
env:
84+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
85+
with:
86+
upload_url: ${{ steps.create_release.outputs.upload_url }}
87+
asset_path: ./${{ env.repo_name }}.zip
88+
asset_name: ${{ env.repo_name }}.zip
89+
asset_content_type: application/zip

0 commit comments

Comments
 (0)