Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .ci/files/prepare_release_notes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
set -e -o pipefail

outfile="release_notes_prepared.md"
infile="ReleaseNotes.md"

if [ ! -e "$infile" ]; then
echo "File ${infile} not found!"
exit 1
fi


# Extract the release notes.
# Note: "|| test $? -eq 141" is added to ignore SIGPIPE errors when head finishes before grep is done.
BEGIN_LINE=$( (grep -n "^## " "${infile}" || test $? -eq 141) | head -1|cut -d ":" -f 1)
END_LINE=$( (grep -n "^## " "${infile}" || test $? -eq 141) | head -2|tail -1|cut -d ":" -f 1)
END_LINE=$((END_LINE - 1))
EXTRACT=$(head -$END_LINE "${infile}" | tail -$((END_LINE - BEGIN_LINE)))

RELEASE_BODY="A new PMD for Eclipse plugin version has been released.
It is available via the update site: https://pmd.github.io/pmd-eclipse-plugin-p2-site/

$EXTRACT
"
echo "${RELEASE_BODY}" > "${outfile}"
echo "Created file ${outfile}"
24 changes: 15 additions & 9 deletions .ci/files/regenerate_metadata.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
#!/bin/bash

echo "Regenerating metadata for p2-site..."
local releases=($(find . -maxdepth 1 -type d -regex "\./[0-9]+\.[0-9]+\.[0-9]+\..*" -printf '%f\n'| tr '.' '\0' | sort -t '\0' -k1,1nr -k2,2nr -k3,3nr -k4dr |awk -F '\0' '{printf "%s.%s.%s.%s\n", $1, $2, $3, $4}'))
mapfile -t releases < <(find . -maxdepth 1 -type d -regex "\./[0-9]+\.[0-9]+\.[0-9]+\..*" -printf '%f\n'| tr '.' '\0' | sort -t '\0' -k1,1nr -k2,2nr -k3,3nr -k4dr |awk -F '\0' '{printf "%s.%s.%s.%s\n", $1, $2, $3, $4}')
# remove old releases
for i in "${releases[@]:5}"; do
pmd_ci_log_info "Removing old release $i..."
echo " Removing old release $i..."
rm -rf "$i"
done
releases=("${releases[@]:0:5}")

# regenerate metadata
local now
now=$(date +%s000)
local children=""
local children_index=""
children=""
children_index=""
for i in "${releases[@]}"; do
echo " Adding release $i"
children="${children} <child location=\"$i\"/>\n"
children_index="${children_index} * [$i]($i/)\n"
echo "This is a Eclipse Update Site for the [PMD Eclipse Plugin](https://github.com/pmd/pmd-eclipse-plugin/) ${i}.
Expand All @@ -33,8 +33,8 @@ Use <https://pmd.github.io/pmd-eclipse-plugin-p2-site/${i}/> to install the plug
git add "$i"/index.md
done

local site_name="PMD for Eclipse - Update Site"
local artifactsTemplate="<?xml version=\"1.0\" encoding=\"UTF-8\"?>
site_name="PMD for Eclipse - Update Site"
artifactsTemplate="<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<?compositeArtifactRepository version=\"1.0.0\"?>
<repository name=\"${site_name}\" type=\"org.eclipse.equinox.internal.p2.artifact.repository.CompositeArtifactRepository\" version=\"1.0.0\">
<properties size=\"2\">
Expand All @@ -45,8 +45,9 @@ local artifactsTemplate="<?xml version=\"1.0\" encoding=\"UTF-8\"?>
${children} </children>
</repository>"
echo -e "${artifactsTemplate}" > compositeArtifacts.xml
git add compositeArtifacts.xml

local contentTemplate="<?xml version=\"1.0\" encoding=\"UTF-8\"?>
contentTemplate="<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<?compositeMetadataRepository version=\"1.0.0\"?>
<repository name=\"${site_name}\" type=\"org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepository\" version=\"1.0.0\">
<properties size=\"2\">
Expand All @@ -57,12 +58,14 @@ local contentTemplate="<?xml version=\"1.0\" encoding=\"UTF-8\"?>
${children} </children>
</repository>"
echo -e "${contentTemplate}" > compositeContent.xml
git add compositeContent.xml

# p2.index
local p2_index="version = 1
p2_index="version = 1
metadata.repository.factory.order = compositeContent.xml,\!
artifact.repository.factory.order = compositeArtifacts.xml,\!"
echo -e "${p2_index}" > p2.index
git add p2.index

# regenerate index.md
echo -e "This is a composite Eclipse Update Site for the [PMD Eclipse Plugin](https://github.com/pmd/pmd-eclipse-plugin/).
Expand All @@ -78,4 +81,7 @@ ${children_index}
For older versions, see <https://sourceforge.net/projects/pmd/files/pmd-eclipse/zipped/>

" > index.md
git add index.md

echo "Done."

31 changes: 6 additions & 25 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,7 @@ jobs:
with:
name: update-site
- name: Prepare Release Notes
run: |
# extract the release notes
BEGIN_LINE=$(grep -n "^## " ReleaseNotes.md|head -1|cut -d ":" -f 1)
END_LINE=$(grep -n "^## " ReleaseNotes.md|head -2|tail -1|cut -d ":" -f 1)
END_LINE=$((END_LINE - 1))

RELEASE_BODY="A new PMD for Eclipse plugin version has been released.
It is available via the update site: https://pmd.github.io/pmd-eclipse-plugin-p2-site/

$(head -$END_LINE ReleaseNotes.md | tail -$((END_LINE - BEGIN_LINE)))
"
echo "${RELEASE_BODY}" > release_notes_prepared.md
run: .ci/files/prepare_release_notes.sh
- name: Create Release
env:
# Token required for GH CLI:
Expand Down Expand Up @@ -208,7 +197,7 @@ jobs:
uploadUrl="${PMD_SF_USER}@web.sourceforge.net:/home/frs/project/pmd/pmd-eclipse/zipped/"
rsync -avh \
"net.sourceforge.pmd.eclipse.p2updatesite-${VERSION}.zip" \
"${uploadUrl}/net.sourceforge.pmd.eclipse.p2updatesite-SNAPSHOT.zip"
"${uploadUrl}/net.sourceforge.pmd.eclipse.p2updatesite-${VERSION}.zip"

- name: Cleanup ssh
if: ${{ always() }}
Expand All @@ -226,6 +215,9 @@ jobs:
run:
shell: bash
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_branch }}
- uses: actions/download-artifact@v4
with:
name: update-site
Expand Down Expand Up @@ -278,18 +270,7 @@ jobs:
with:
ref: ${{ github.event.workflow_run.head_branch }}
- name: Prepare Release Notes
run: |
# extract the release notes
BEGIN_LINE=$(grep -n "^## " ReleaseNotes.md|head -1|cut -d ":" -f 1)
END_LINE=$(grep -n "^## " ReleaseNotes.md|head -2|tail -1|cut -d ":" -f 1)
END_LINE=$((END_LINE - 1))

RELEASE_BODY="A new PMD for Eclipse plugin version has been released.
It is available via the update site: https://pmd.github.io/pmd-eclipse-plugin-p2-site/

$(head -$END_LINE ReleaseNotes.md | tail -$((END_LINE - BEGIN_LINE)))
"
echo "${RELEASE_BODY}" > release_notes_prepared.md
run: .ci/files/prepare_release_notes.sh
- name: Create Blog Post
id: upload
env:
Expand Down