Skip to content

Commit e804b60

Browse files
committed
Merge pull request #142 from adangel:issue-140-update-site
Use new Github Pages based update site #142
2 parents 5f43e9f + 7005e67 commit e804b60

File tree

4 files changed

+148
-22
lines changed

4 files changed

+148
-22
lines changed

.ci/build.sh

Lines changed: 127 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Exit this script immediately if a command/function exits with a non-zero status.
44
set -e
55

6-
SCRIPT_INCLUDES="log.bash utils.bash setup-secrets.bash openjdk.bash maven.bash"
6+
SCRIPT_INCLUDES="log.bash utils.bash setup-secrets.bash openjdk.bash maven.bash sourceforge-api.bash"
77
# shellcheck source=inc/fetch_ci_scripts.bash
88
source "$(dirname "$0")/inc/fetch_ci_scripts.bash" && fetch_ci_scripts
99

@@ -62,6 +62,25 @@ function snapshot_build() {
6262
cd net.sourceforge.pmd.eclipse.p2updatesite
6363
./cleanup-bintray-snapshots.sh
6464
)
65+
66+
# Add snapshot to update site
67+
pmd_ci_log_info "Updating pmd-eclipse-plugin-p2-site..."
68+
prepare_local_p2_site
69+
(
70+
cd current-p2-site
71+
72+
rm -rf snapshot
73+
unzip -q -d snapshot "../net.sourceforge.pmd.eclipse.p2updatesite/target/net.sourceforge.pmd.eclipse.p2updatesite-*.zip"
74+
echo -e "This is a Eclipse Update Site for the PMD Eclipse Plugin for version ${PMD_CI_MAVEN_PROJECT_VERSION} ($(date -Iminutes)).\n\n<https://github.com/pmd/pmd-eclipse-plugin/>" > snapshot/index.md
75+
git add snapshot
76+
77+
# create a new single commit
78+
git checkout --orphan=gh-pages-2
79+
git commit -a -m "Update pmd/pmd-eclipse-plugin-p2-site"
80+
git push --force origin gh-pages-2:gh-pages
81+
pmd_ci_log_success "Successfully updated https://pmd.github.io/pmd-eclipse-plugin-p2-site/"
82+
)
83+
6584
pmd_ci_log_group_end
6685
}
6786

@@ -73,7 +92,7 @@ function release_build() {
7392
pmd_ci_gh_releases_createDraftRelease "${PMD_CI_TAG}" "$(git rev-list -n 1 "${PMD_CI_TAG}")"
7493
GH_RELEASE="$RESULT"
7594

76-
# Deploy the update site to bintray
95+
# Build and deploy the update site to bintray
7796
xvfb-run --auto-servernum ./mvnw clean verify --show-version --errors --batch-mode \
7897
--no-transfer-progress \
7998
--activate-profiles release-composite
@@ -88,17 +107,121 @@ function release_build() {
88107
END_LINE=$((END_LINE - 1))
89108

90109
RELEASE_BODY="A new PMD for Eclipse plugin version has been released.
91-
It is available via the update site: https://dl.bintray.com/pmd/pmd-eclipse-plugin/updates/
110+
It is available via the update site: https://pmd.github.io/pmd-eclipse-plugin-p2-site/
92111
93112
$(head -$END_LINE ReleaseNotes.md | tail -$((END_LINE - BEGIN_LINE)))
94113
"
95114

96115
pmd_ci_gh_releases_updateRelease "$GH_RELEASE" "$RELEASE_NAME" "$RELEASE_BODY"
97116

98-
# Publish release
117+
# Upload it to sourceforge
118+
pmd_ci_sourceforge_uploadFile "pmd-eclipse/zipped" "net.sourceforge.pmd.eclipse.p2updatesite/target/net.sourceforge.pmd.eclipse.p2updatesite-${PMD_CI_MAVEN_PROJECT_VERSION}.zip"
119+
120+
# Add new release to update site
121+
pmd_ci_log_info "Updating pmd-eclipse-plugin-p2-site..."
122+
prepare_local_p2_site
123+
(
124+
cd current-p2-site
125+
126+
unzip -q -d "${PMD_CI_MAVEN_PROJECT_VERSION}" "net.sourceforge.pmd.eclipse.p2updatesite/target/net.sourceforge.pmd.eclipse.p2updatesite-${PMD_CI_MAVEN_PROJECT_VERSION}.zip"
127+
git add "${PMD_CI_MAVEN_PROJECT_VERSION}"
128+
regenerate_metadata
129+
130+
# create a new single commit
131+
git checkout --orphan=gh-pages-2
132+
git commit -a -m "Update pmd/pmd-eclipse-plugin-p2-site"
133+
git push --force origin gh-pages-2:gh-pages
134+
pmd_ci_log_success "Successfully updated https://pmd.github.io/pmd-eclipse-plugin-p2-site/"
135+
)
136+
137+
# Publish release - this sends out notifications on github
99138
pmd_ci_gh_releases_publishRelease "$GH_RELEASE"
100139

101140
pmd_ci_log_group_end
102141
}
103142

143+
144+
function prepare_local_p2_site() {
145+
pmd_ci_log_info "Preparing local copy of p2-site..."
146+
rm -rf current-p2-site
147+
mkdir current-p2-site
148+
(
149+
cd current-p2-site
150+
git init -q
151+
git config user.name "PMD CI (pmd-bot)"
152+
git config user.email "[email protected]"
153+
git remote add origin [email protected]:pmd/pmd-eclipse-plugin-p2-site.git
154+
git pull origin gh-pages
155+
)
156+
}
157+
158+
function regenerate_metadata() {
159+
pmd_ci_log_info "Regenerating metadata for p2-site..."
160+
local releases=($(find . -maxdepth 1 -type d -regex "\./[0-9]+\.[0-9]+\.[0-9]+\..*" -printf '%TY-%Tm-%Td\0%f\n' | sort -t '\0' -r|awk -F '\0' '{print $2}'))
161+
# remove old releases
162+
for i in "${releases[@]:5}"; do
163+
pmd_ci_log_info "Removing old release $i..."
164+
rm -rf "$i"
165+
done
166+
releases=("${releases[@]:0:5}")
167+
168+
# regenerate metadata
169+
local now
170+
now=$(date +%s000)
171+
local children=""
172+
local children_index=""
173+
for i in "${releases[@]}"; do
174+
children="${children} <child location=\"$i\"/>\n"
175+
children_index="${children_index} * [$i]($i/)\n"
176+
echo -e "This is a Eclipse Update Site for the PMD Eclipse Plugin for version $i.\n\n<https://github.com/pmd/pmd-eclipse-plugin/>" > "$i"/index.md
177+
git add "$i"/index.md
178+
done
179+
180+
local site_name="PMD for Eclipse - Update Site"
181+
local artifactsTemplate="<?xml version=\"1.0\" encoding=\"UTF-8\"?>
182+
<?compositeArtifactRepository version=\"1.0.0\"?>
183+
<repository name=\"${site_name}\" type=\"org.eclipse.equinox.internal.p2.artifact.repository.CompositeArtifactRepository\" version=\"1.0.0\">
184+
<properties size=\"2\">
185+
<property name=\"p2.timestamp\" value=\"${now}\"/>
186+
<property name=\"p2.atomic.composite.loading\" value=\"true\"/>
187+
</properties>
188+
<children size=\"${#releases[@]}\">
189+
${children} </children>
190+
</repository>"
191+
echo -e "${artifactsTemplate}" > compositeArtifacts.xml
192+
193+
local contentTemplate="<?xml version=\"1.0\" encoding=\"UTF-8\"?>
194+
<?compositeMetadataRepository version=\"1.0.0\"?>
195+
<repository name=\"${site_name}\" type=\"org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepository\" version=\"1.0.0\">
196+
<properties size=\"2\">
197+
<property name=\"p2.timestamp\" value=\"${now}\"/>
198+
<property name=\"p2.atomic.composite.loading\" value=\"true\"/>
199+
</properties>
200+
<children size=\"${#releases[@]}\">
201+
${children} </children>
202+
</repository>"
203+
echo -e "${contentTemplate}" > compositeContent.xml
204+
205+
# p2.index
206+
local p2_index="version = 1
207+
metadata.repository.factory.order = compositeContent.xml,\!
208+
artifact.repository.factory.order = compositeArtifacts.xml,\!"
209+
echo -e "${p2_index}" > p2.index
210+
211+
# regenerate index.md
212+
local index_md="This URL is a composite Eclipse Update Site for the PMD Eclipse Plugin.
213+
214+
Github: <https://github.com/pmd/pmd-eclipse-plugin/>
215+
216+
----
217+
218+
Versions available at <https://pmd.github.io/pmd-eclipse-plugin-p2-site/>:
219+
220+
${children_index}
221+
222+
For older versions, see <https://sourceforge.net/projects/pmd/files/pmd-eclipse/zipped/>
223+
"
224+
echo -e "${index_md}" > index.md
225+
}
226+
104227
build

README.md

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ Release Notes: <https://github.com/pmd/pmd-eclipse-plugin/blob/master/ReleaseNot
77

88
Eclipse Update Site:
99

10-
* Releases: <https://dl.bintray.com/pmd/pmd-eclipse-plugin/updates/>
11-
* Snapshots: <https://dl.bintray.com/pmd/pmd-eclipse-plugin/snapshots/updates/>
10+
* Releases: <https://pmd.github.io/pmd-eclipse-plugin-p2-site/>
11+
* Snapshots: <https://pmd.github.io/pmd-eclipse-plugin-p2-site/snapshot/>
1212

1313
Marketplace: [![Drag to your running Eclipse workspace. Requires Eclipse Marketplace Client](https://marketplace.eclipse.org/sites/all/themes/solstice/public/images/marketplace/btn-install.png)](http://marketplace.eclipse.org/marketplace-client-intro?mpc_install=2755329)
1414

@@ -69,16 +69,12 @@ You can run eclipse with debugging enabled and connect to it via remote debuggin
6969

7070
### Releasing and updating the official eclipse update site
7171

72-
From now on, we use [bintray](https://bintray.com) for hosting the eclipse update site.
73-
There is a nice [blog post by Lorenzo Bettini](http://www.lorenzobettini.it/2016/02/publish-an-eclipse-p2-composite-repository-on-bintray/), which explains how it is done. There is also an [example repository](https://github.com/LorenzoBettini/p2composite-bintray-example) on github.
72+
The update site is hosted on github as a Github Pages site of the repository
73+
<https://github.com/pmd/pmd-eclipse-plugin-p2-site/>.
7474

75-
76-
Have a look at the `net.sourceforge.pmd.eclipse.p2updatesite` module, there you see
77-
78-
* a profile `release-composite` which enables the steps
79-
* the ant script `bintray.ant` which is used to upload and download the site
80-
* the ant script `packaging-p2composite.ant` which is used to modify the metadata of the
81-
p2 repo locally before uploading
75+
The release script running on Github Actions will automatically update the repository pmd-eclipse-plugin-p2-site and
76+
add the new release, update the repository metadata (compositeContent.xml and compositeArtifacts.xml
77+
as well as index.md) and push the changes.
8278

8379
The release happens in two phases:
8480

@@ -89,7 +85,7 @@ The release happens in two phases:
8985
* Update the changelog for the next version
9086
* Update the versions
9187
2. Push the changes and the tag. The [Github Actions build](https://github.com/pmd/pmd-eclipse-plugin/actions) will
92-
then publish the new version on [bintray](https://dl.bintray.com/pmd/pmd-eclipse-plugin/) and
88+
then publish the new version on [update site](https://github.com/pmd/pmd-eclipse-plugin-p2-site/) and
9389
[github releases](https://github.com/pmd/pmd-eclipse-plugin/releases)
9490

9591

@@ -111,7 +107,7 @@ The release happens in two phases:
111107
echo
112108
echo "Press enter to continue..."
113109
read
114-
./mvnw -Dtycho.mode=maven org.eclipse.tycho:tycho-versions-plugin:set-version -DnewVersion=$VERSION.$BUILDQUALIFIER
110+
./mvnw -Dtycho.mode=maven org.eclipse.tycho:tycho-versions-plugin:1.7.0:set-version -DnewVersion=$VERSION.$BUILDQUALIFIER
115111
git commit -a -m "Prepare release pmd-eclipse-plugin $VERSION.$BUILDQUALIFIER"
116112
git tag $VERSION.$BUILDQUALIFIER
117113
echo "Create (temporary) release branch"
@@ -126,7 +122,7 @@ The release happens in two phases:
126122
read
127123

128124
echo "Updating version in master to next"
129-
./mvnw -Dtycho.mode=maven org.eclipse.tycho:tycho-versions-plugin:set-version -DnewVersion=$NEXT-SNAPSHOT
125+
./mvnw -Dtycho.mode=maven org.eclipse.tycho:tycho-versions-plugin:1.7.0:set-version -DnewVersion=$NEXT-SNAPSHOT
130126
git commit -a -m "Prepare next pmd-eclipse-plugin development version $NEXT-SNAPSHOT"
131127

132128
echo Checkout the release branch and build the plugin
@@ -166,7 +162,7 @@ You can use the following template:
166162
PMD for Eclipse $VERSION.$BUILDQUALIFIER released
167163

168164
A new PMD for Eclipse plugin version has been released.
169-
It is available via the update site: <https://dl.bintray.com/pmd/pmd-eclipse-plugin/updates/>
165+
It is available via the update site: <https://pmd.github.io/pmd-eclipse-plugin-p2-site/>
170166

171167
* Release Notes: <https://github.com/pmd/pmd-eclipse-plugin/blob/$VERSION.$BUILDQUALIFIER/ReleaseNotes.md>
172168

ReleaseNotes.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,24 @@ Installation instructions: <https://pmd.github.io/eclipse/>
44

55
Eclipse Update Site:
66

7-
* Releases: <https://dl.bintray.com/pmd/pmd-eclipse-plugin/updates/>
8-
* Snapshots: <https://dl.bintray.com/pmd/pmd-eclipse-plugin/snapshots/updates/>
7+
* Releases: <https://pmd.github.io/pmd-eclipse-plugin-p2-site/>
8+
* Snapshots: <https://pmd.github.io/pmd-eclipse-plugin-p2-site/snapshot/>
99

1010
## ????: 4.22.0.v????
1111

1212
This is a minor release.
1313

1414
### New and noteworthy
1515

16+
* The update site moved from Bintray to Github Pages. The new URL is from now on:
17+
<https://pmd.github.io/pmd-eclipse-plugin-p2-site/>
18+
* Archives of the old versions can be found on sourceforge:
19+
<https://sourceforge.net/projects/pmd/files/pmd-eclipse/zipped/>
20+
1621
### Fixed Issues
1722

23+
* [#140](https://github.com/pmd/pmd-eclipse-plugin/issues/140): Use gh pages for update site
24+
1825
### API Changes
1926

2027
### External Contributions

net.sourceforge.pmd.eclipse/feature.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
</license>
2121

2222
<url>
23-
<update label="%feature.update_site_name" url="https://dl.bintray.com/pmd/pmd-eclipse-plugin/updates/"/>
23+
<update label="%feature.update_site_name" url="https://pmd.github.io/pmd-eclipse-plugin-p2-site/"/>
2424
</url>
2525

2626
<requires>

0 commit comments

Comments
 (0)