Skip to content

Commit 2a35d67

Browse files
committed
Switch to composite P2 repository with versioned subdirectories
Each release is deployed to a versioned subdirectory (e.g. 0.1.0/). Root composite files are regenerated on every deploy to include all versions, enabling auto-updates and version selection in DBeaver.
1 parent cb6b18b commit 2a35d67

File tree

1 file changed

+62
-3
lines changed

1 file changed

+62
-3
lines changed

.github/workflows/deploy.yaml

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,17 @@ jobs:
6262
AWS_ACCESS_KEY_ID: ${{ secrets.YC_KEY_ID }}
6363
AWS_SECRET_ACCESS_KEY: ${{ secrets.YC_SECRET }}
6464
run: |
65+
VERSION="${{ github.ref_name }}"
66+
VERSION_NUM="${VERSION#v}"
6567
REPO_DIR="repository/target/repository"
66-
S3_DEST="s3://ydb-dbeaver-plugin/"
68+
S3_BASE="s3://ydb-dbeaver-plugin"
69+
S3_DEST="${S3_BASE}/${VERSION_NUM}/"
6770
YC_ENDPOINT="https://storage.yandexcloud.net"
6871
72+
# Upload versioned P2 repository
6973
aws s3 sync "$REPO_DIR" "$S3_DEST" \
7074
--endpoint-url "$YC_ENDPOINT" \
71-
--delete --no-progress \
75+
--no-progress \
7276
--exclude '*' --include '*.jar' \
7377
--content-type 'application/java-archive'
7478
@@ -91,7 +95,62 @@ jobs:
9195
--endpoint-url "$YC_ENDPOINT" \
9296
--no-progress
9397
94-
echo "Deployed to: ${YC_ENDPOINT}/ydb-dbeaver-plugin"
98+
# Collect all version subdirectories from S3
99+
VERSIONS=$(aws s3 ls "${S3_BASE}/" \
100+
--endpoint-url "$YC_ENDPOINT" \
101+
| awk '/\/$/ {print $NF}' | sed 's|/$||' | sort -V)
102+
103+
CHILDREN_COUNT=$(echo "$VERSIONS" | wc -l | tr -d ' ')
104+
TIMESTAMP=$(date +%s)000
105+
106+
CHILDREN=""
107+
while IFS= read -r v; do
108+
CHILDREN="${CHILDREN} <child location='${v}'/>"$'\n'
109+
done <<< "$VERSIONS"
110+
111+
# Generate compositeArtifacts.xml
112+
cat > compositeArtifacts.xml << EOF
113+
<?xml version='1.0' encoding='UTF-8'?>
114+
<?compositeArtifactRepository version='1.0.0'?>
115+
<repository name='YDB DBeaver Plugin' type='org.eclipse.equinox.internal.p2.artifact.repository.CompositeArtifactRepository' version='1.0.0'>
116+
<properties size='1'>
117+
<property name='p2.timestamp' value='${TIMESTAMP}'/>
118+
</properties>
119+
<children size='${CHILDREN_COUNT}'>
120+
${CHILDREN} </children>
121+
</repository>
122+
EOF
123+
124+
# Generate compositeContent.xml
125+
cat > compositeContent.xml << EOF
126+
<?xml version='1.0' encoding='UTF-8'?>
127+
<?compositeMetadataRepository version='1.0.0'?>
128+
<repository name='YDB DBeaver Plugin' type='org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepository' version='1.0.0'>
129+
<properties size='1'>
130+
<property name='p2.timestamp' value='${TIMESTAMP}'/>
131+
</properties>
132+
<children size='${CHILDREN_COUNT}'>
133+
${CHILDREN} </children>
134+
</repository>
135+
EOF
136+
137+
# Generate p2.index
138+
cat > p2.index << EOF
139+
version=1
140+
metadata.repository.factory.order=compositeContent,\!
141+
artifact.repository.factory.order=compositeArtifacts,\!
142+
EOF
143+
144+
# Upload composite files to bucket root
145+
aws s3 cp compositeArtifacts.xml "${S3_BASE}/compositeArtifacts.xml" \
146+
--endpoint-url "$YC_ENDPOINT" --content-type 'application/xml'
147+
aws s3 cp compositeContent.xml "${S3_BASE}/compositeContent.xml" \
148+
--endpoint-url "$YC_ENDPOINT" --content-type 'application/xml'
149+
aws s3 cp p2.index "${S3_BASE}/p2.index" \
150+
--endpoint-url "$YC_ENDPOINT" --content-type 'text/plain'
151+
152+
echo "Deployed ${VERSION_NUM} to: ${YC_ENDPOINT}/ydb-dbeaver-plugin/${VERSION_NUM}"
153+
echo "Composite repository updated with versions: $(echo $VERSIONS | tr '\n' ' ')"
95154
96155
- name: Create GitHub Release
97156
uses: softprops/action-gh-release@v2

0 commit comments

Comments
 (0)