Skip to content

Commit c7502f6

Browse files
authored
Merge pull request #1161 from jdaugherty/7.0.x
ci: add release abort workflow & update verification script to check svn artifacts
2 parents 5ddf8ed + 2ea1aea commit c7502f6

File tree

3 files changed

+175
-9
lines changed

3 files changed

+175
-9
lines changed
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one or more
2+
# contributor license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright ownership.
4+
# The ASF licenses this file to You under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance with
6+
# the License. You may obtain a copy of the License at
7+
#
8+
# https://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
name: "Release - Abort Release"
17+
on:
18+
workflow_dispatch:
19+
inputs:
20+
release_tag:
21+
description: 'Release tag (e.g., v7.0.0-M5)'
22+
required: true
23+
type: string
24+
permissions:
25+
contents: write
26+
actions: write
27+
jobs:
28+
abort:
29+
name: "Abort Release"
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: "Output Agent IP" # in the event RAO blocks this agent, this can be used to debug it
33+
run: curl -s https://api.ipify.org
34+
- name: "Setup SVN and Tools"
35+
run: sudo apt-get install -y subversion subversion-tools tree
36+
- name: "Extract repository name"
37+
id: extract_repository_name
38+
run: |
39+
echo "repository_name=${GITHUB_REPOSITORY##*/}" >> $GITHUB_OUTPUT
40+
- name: "Extract release version"
41+
id: release_version
42+
run: |
43+
version="${{ github.event.inputs.release_tag }}"
44+
version="${version#v}"
45+
echo "Extracted version: $version"
46+
echo "value=${version}" >> $GITHUB_OUTPUT
47+
- name: "Drop staging repository from Nexus"
48+
continue-on-error: true
49+
env:
50+
NEXUS_STAGE_DEPLOYER_USER: ${{ secrets.NEXUS_STAGE_DEPLOYER_USER }}
51+
NEXUS_STAGE_DEPLOYER_PW: ${{ secrets.NEXUS_STAGE_DEPLOYER_PW }}
52+
run: |
53+
export REPO_DESCRIPTION="${{ steps.extract_repository_name.outputs.repository_name }}:${{ steps.release_version.outputs.value }}"
54+
export STAGING_REPOSITORY_ID=$(curl -s -u "$NEXUS_STAGE_DEPLOYER_USER:$NEXUS_STAGE_DEPLOYER_PW" -H "Accept: application/json" \
55+
"https://repository.apache.org/service/local/staging/profile_repositories/${{ secrets.STAGING_PROFILE_ID }}" |
56+
jq -r '.data[] | select(.description=="'"$REPO_DESCRIPTION"'") | .repositoryId')
57+
58+
test -n "$STAGING_REPOSITORY_ID" || { echo "No repo with that description"; exit 1; }
59+
60+
response=$(curl -s --request POST -u "$NEXUS_STAGE_DEPLOYER_USER:$NEXUS_STAGE_DEPLOYER_PW" \
61+
--url https://repository.apache.org/service/local/staging/bulk/drop \
62+
--header 'Content-Type: application/json' \
63+
--header 'Accept: application/json' \
64+
--header 'User-Agent: Grails Github Actions' \
65+
--data '{ "data" : {"stagedRepositoryIds":["'"$STAGING_REPOSITORY_ID"'"], "description":"Drop '"$STAGING_REPOSITORY_ID"'." } }')
66+
67+
if [ ! -z "$response" ]; then
68+
echo "Error while dropping staged repository $STAGING_REPOSITORY_ID : $response."
69+
exit 1
70+
else
71+
echo "Successfully dropped repository $STAGING_REPOSITORY_ID."
72+
fi
73+
- name: "Remove Staged Artifacts"
74+
continue-on-error: true
75+
env:
76+
SVN_USERNAME: ${{ secrets.SVC_DIST_GRAILS_USERNAME }}
77+
SVN_PASSWORD: ${{ secrets.SVC_DIST_GRAILS_PASSWORD }}
78+
run: |
79+
export VERSION="${{ steps.release_version.outputs.value }}"
80+
svnmucc --username "$SVN_USERNAME" --password "$SVN_PASSWORD" --non-interactive \
81+
-m "Remove grails dev version $VERSION" \
82+
rm "https://dist.apache.org/repos/dist/dev/incubator/grails/spring-security/$VERSION"
83+
- name: "Cancel GitHub Actions"
84+
continue-on-error: true
85+
env:
86+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87+
OWNER: ${{ github.repository_owner }}
88+
REPO: ${{ steps.extract_repository_name.outputs.repository_name }}
89+
run: |
90+
for status in queued in_progress; do
91+
curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
92+
-H "Accept: application/vnd.github+json" \
93+
"https://api.github.com/repos/$OWNER/$REPO/actions/runs?event=release&status=$status&per_page=100" |
94+
jq -r '.workflow_runs[].id'
95+
done > run-ids.txt
96+
97+
while read run_id; do
98+
echo "cancelling $run_id"
99+
curl -s -X POST \
100+
-H "Authorization: Bearer $GITHUB_TOKEN" \
101+
-H "Accept: application/vnd.github+json" \
102+
"https://api.github.com/repos/$OWNER/$REPO/actions/runs/$run_id/cancel"
103+
done < run-ids.txt
104+
rm -f run-ids.txt || true
105+
- name: "Remove GitHub Release & Tag"
106+
env:
107+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
108+
TAG: ${{ github.event.inputs.release_tag }}
109+
OWNER: ${{ github.repository_owner }}
110+
REPO: ${{ steps.extract_repository_name.outputs.repository_name }}
111+
run: |
112+
set -euo pipefail
113+
114+
if release_json="$(gh api -H 'Accept: application/vnd.github+json' \
115+
"/repos/$OWNER/$REPO/releases/tags/$TAG" 2>/dev/null)"; then
116+
if [ "$(jq -r '.prerelease' <<<"$release_json")" != "true" ]; then
117+
echo "❌ Release $TAG exists but is *not* marked as a pre-release. Aborting."
118+
exit 1
119+
fi
120+
121+
release_id="$(jq -r '.id' <<<"$release_json")"
122+
echo "Deleting pre-release $release_id linked to tag $TAG"
123+
gh api -X DELETE "/repos/$OWNER/$REPO/releases/$release_id"
124+
else
125+
echo "No GitHub release found for tag $TAG – skipping release deletion"
126+
fi
127+
128+
ref="tags/$TAG"
129+
echo "Deleting git ref $ref"
130+
gh api -X DELETE "/repos/$OWNER/$REPO/git/refs/$ref" || echo "Tag $TAG already absent"

.github/workflows/release.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,21 +157,21 @@ jobs:
157157
run: |
158158
cd ${{ needs.publish.outputs.extract_repository_name }}
159159
release_url=$(gh release view v${{ needs.publish.outputs.release_version }} --json assets --repo ${{ github.repository }} --jq '.assets[] | select(.name == "CHECKSUMS.txt") | .url')
160-
curl -L -H "Authorization: token $GH_TOKEN" -o CHECKSUMS "$release_url"
160+
curl -f -L -H "Authorization: token $GH_TOKEN" -o CHECKSUMS "$release_url"
161161
- name: "Download PUBLISHED_ARTIFACTS.txt and rename to PUBLISHED_ARTIFACTS"
162162
env:
163163
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
164164
run: |
165165
cd ${{ needs.publish.outputs.extract_repository_name }}
166166
release_url=$(gh release view v${{ needs.publish.outputs.release_version }} --json assets --repo ${{ github.repository }} --jq '.assets[] | select(.name == "PUBLISHED_ARTIFACTS.txt") | .url')
167-
curl -L -H "Authorization: token $GH_TOKEN" -o PUBLISHED_ARTIFACTS "$release_url"
167+
curl -f -L -H "Authorization: token $GH_TOKEN" -o PUBLISHED_ARTIFACTS "$release_url"
168168
- name: "Download BUILD_DATE.txt and rename to BUILD_DATE"
169169
env:
170170
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
171171
run: |
172172
cd ${{ needs.publish.outputs.extract_repository_name }}
173173
release_url=$(gh release view v${{ needs.publish.outputs.release_version }} --json assets --repo ${{ github.repository }} --jq '.assets[] | select(.name == "BUILD_DATE.txt") | .url')
174-
curl -L -H "Authorization: token $GH_TOKEN" -o BUILD_DATE "$release_url"
174+
curl -f -L -H "Authorization: token $GH_TOKEN" -o BUILD_DATE "$release_url"
175175
- name: "Ensure source files use common date"
176176
run: |
177177
SOURCE_DATE_EPOCH=$(cat ${{ needs.publish.outputs.extract_repository_name }}/BUILD_DATE)
@@ -280,9 +280,9 @@ jobs:
280280
cd dev-repo
281281
mkdir -p $VERSION/sources
282282
cd $VERSION/sources
283-
curl -LO https://github.com/apache/grails-core/releases/download/$TAG/apache-${{ needs.publish.outputs.extract_repository_name }}-$VERSION-incubating-src.zip
284-
curl -LO https://github.com/apache/grails-core/releases/download/$TAG/apache-${{ needs.publish.outputs.extract_repository_name }}-$VERSION-incubating-src.zip.sha512
285-
curl -LO https://github.com/apache/grails-core/releases/download/$TAG/apache-${{ needs.publish.outputs.extract_repository_name }}-$VERSION-incubating-src.zip.asc
283+
curl -f -LO https://github.com/apache/${{ needs.publish.outputs.extract_repository_name }}/releases/download/$TAG/apache-${{ needs.publish.outputs.extract_repository_name }}-$VERSION-incubating-src.zip
284+
curl -f -LO https://github.com/apache/${{ needs.publish.outputs.extract_repository_name }}/releases/download/$TAG/apache-${{ needs.publish.outputs.extract_repository_name }}-$VERSION-incubating-src.zip.sha512
285+
curl -f -LO https://github.com/apache/${{ needs.publish.outputs.extract_repository_name }}/releases/download/$TAG/apache-${{ needs.publish.outputs.extract_repository_name }}-$VERSION-incubating-src.zip.asc
286286
echo "Downloaded the following files:"
287287
ls -l
288288
- name: "Upload distributions"

etc/bin/download-release-artifacts.sh

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ set -e
2121

2222
PROJECT_NAME='grails-spring-security'
2323
REPO_NAME='apache/grails-spring-security'
24+
SVN_FOLDER='spring-security'
2425
RELEASE_TAG=$1
2526
DOWNLOAD_LOCATION="${2:-downloads}"
2627

@@ -35,6 +36,41 @@ mkdir -p "${DOWNLOAD_LOCATION}"
3536
VERSION=${RELEASE_TAG#v}
3637

3738
# Source distro
38-
curl -L -o "${DOWNLOAD_LOCATION}/apache-${PROJECT_NAME}-$VERSION-incubating-src.zip" "https://github.com/${REPO_NAME}/releases/download/$RELEASE_TAG/apache-${PROJECT_NAME}-$VERSION-incubating-src.zip"
39-
curl -L -o "${DOWNLOAD_LOCATION}/apache-${PROJECT_NAME}-$VERSION-incubating-src.zip.asc" "https://github.com/${REPO_NAME}/releases/download/$RELEASE_TAG/apache-${PROJECT_NAME}-$VERSION-incubating-src.zip.asc"
40-
curl -L -o "${DOWNLOAD_LOCATION}/apache-${PROJECT_NAME}-$VERSION-incubating-src.zip.sha512" "https://github.com/${REPO_NAME}/releases/download/$RELEASE_TAG/apache-${PROJECT_NAME}-$VERSION-incubating-src.zip.sha512"
39+
echo "Downloading GitHub Release files"
40+
curl -f -L -o "${DOWNLOAD_LOCATION}/github-apache-${PROJECT_NAME}-${VERSION}-incubating-src.zip" "https://github.com/${REPO_NAME}/releases/download/${RELEASE_TAG}/apache-${PROJECT_NAME}-${VERSION}-incubating-src.zip"
41+
curl -f -L -o "${DOWNLOAD_LOCATION}/github-apache-${PROJECT_NAME}-${VERSION}-incubating-src.zip.asc" "https://github.com/${REPO_NAME}/releases/download/${RELEASE_TAG}/apache-${PROJECT_NAME}-${VERSION}-incubating-src.zip.asc"
42+
curl -f -L -o "${DOWNLOAD_LOCATION}/github-apache-${PROJECT_NAME}-${VERSION}-incubating-src.zip.sha512" "https://github.com/${REPO_NAME}/releases/download/${RELEASE_TAG}/apache-${PROJECT_NAME}-${VERSION}-incubating-src.zip.sha512"
43+
44+
echo "Downloading SVN Release files"
45+
curl -f -L -o "${DOWNLOAD_LOCATION}/apache-${PROJECT_NAME}-${VERSION}-incubating-src.zip" "https://dist.apache.org/repos/dist/dev/incubator/grails/${SVN_FOLDER}/${VERSION}/sources/apache-${PROJECT_NAME}-${VERSION}-incubating-src.zip"
46+
curl -f -L -o "${DOWNLOAD_LOCATION}/apache-${PROJECT_NAME}-${VERSION}-incubating-src.zip.asc" "https://dist.apache.org/repos/dist/dev/incubator/grails/${SVN_FOLDER}/${VERSION}/sources/apache-${PROJECT_NAME}-${VERSION}-incubating-src.zip.asc"
47+
curl -f -L -o "${DOWNLOAD_LOCATION}/apache-${PROJECT_NAME}-${VERSION}-incubating-src.zip.sha512" "https://dist.apache.org/repos/dist/dev/incubator/grails/${SVN_FOLDER}/${VERSION}/sources/apache-${PROJECT_NAME}-${VERSION}-incubating-src.zip.sha512"
48+
49+
echo "Comparing SVN vs GitHub Release files"
50+
set +e
51+
52+
cmp -s "${DOWNLOAD_LOCATION}/apache-${PROJECT_NAME}-${VERSION}-incubating-src.zip.asc" "${DOWNLOAD_LOCATION}/github-apache-${PROJECT_NAME}-${VERSION}-incubating-src.zip.asc"
53+
if [ $? -eq 0 ]; then
54+
echo "✅ Identical SVN vs GitHub Upload for apache-${PROJECT_NAME}-${VERSION}-incubating-src.zip.asc"
55+
else
56+
echo "❌Different SVN vs GitHub Upload for apache-${PROJECT_NAME}-${VERSION}-incubating-src.zip.asc"
57+
exit 1
58+
fi
59+
60+
set +e
61+
cmp -s "${DOWNLOAD_LOCATION}/apache-${PROJECT_NAME}-${VERSION}-incubating-src.zip.sha512" "${DOWNLOAD_LOCATION}/github-apache-${PROJECT_NAME}-${VERSION}-incubating-src.zip.sha512"
62+
if [ $? -eq 0 ]; then
63+
echo "✅ Identical SVN vs GitHub Upload for apache-${PROJECT_NAME}-${VERSION}-incubating-src.zip.sha512"
64+
else
65+
echo "❌ Different SVN vs GitHub Upload for apache-${PROJECT_NAME}-${VERSION}-incubating-src.zip.sha512"
66+
exit 1
67+
fi
68+
69+
ZIP_SVN_CHECKSUM=$(shasum -a 512 "${DOWNLOAD_LOCATION}/apache-${PROJECT_NAME}-${VERSION}-incubating-src.zip" | awk '{print $1}')
70+
ZIP_GITHUB_CHECKSUM=$(shasum -a 512 "${DOWNLOAD_LOCATION}/github-apache-${PROJECT_NAME}-${VERSION}-incubating-src.zip" | awk '{print $1}')
71+
if [ "${ZIP_SVN_CHECKSUM}" != "${ZIP_GITHUB_CHECKSUM}" ]; then
72+
echo "❌ Checksum mismatch between SVN and GitHub source zip files"
73+
exit 1
74+
else
75+
echo "✅ Checksum matches between SVN and GitHub source zip files"
76+
fi

0 commit comments

Comments
 (0)