ci: fix publish step - replace go mod zip with python zipfile (go mod zip removed in Go 1.24+)
This commit is contained in:
24
.drone.yml
24
.drone.yml
@@ -78,18 +78,34 @@ steps:
|
|||||||
GITEA_TOKEN:
|
GITEA_TOKEN:
|
||||||
from_secret: gitea_token
|
from_secret: gitea_token
|
||||||
commands:
|
commands:
|
||||||
- apt-get update -q && apt-get install -qy zip python3
|
- apt-get update -q && apt-get install -qy python3
|
||||||
- MODULE=$(go mod edit -json | python3 -c "import json,sys; print(json.load(sys.stdin)['Module']['Path'])")
|
- MODULE=$(go mod edit -json | python3 -c "import json,sys; print(json.load(sys.stdin)['Module']['Path'])")
|
||||||
- VERSION=${DRONE_TAG}
|
- VERSION=${DRONE_TAG}
|
||||||
- echo "Publishing $MODULE@$VERSION"
|
- echo "Publishing $MODULE@$VERSION"
|
||||||
- go mod download
|
- go mod download
|
||||||
- go mod zip /tmp/module.zip "$MODULE@$VERSION"
|
|
||||||
- |
|
- |
|
||||||
curl -sf -X PUT \
|
cat > /tmp/mkzip.py << 'PYEOF'
|
||||||
|
import zipfile, os, sys
|
||||||
|
module, version = sys.argv[1], sys.argv[2]
|
||||||
|
prefix = f'{module}@{version}/'
|
||||||
|
with zipfile.ZipFile('/tmp/module.zip', 'w', zipfile.ZIP_DEFLATED) as zf:
|
||||||
|
for root, dirs, files in os.walk('.'):
|
||||||
|
dirs[:] = [d for d in dirs if not d.startswith('.')]
|
||||||
|
for f in files:
|
||||||
|
if f.startswith('.'): continue
|
||||||
|
path = os.path.join(root, f)
|
||||||
|
zf.write(path, prefix + os.path.relpath(path, '.'))
|
||||||
|
print(f'Zip created: {len(zf.namelist())} files')
|
||||||
|
PYEOF
|
||||||
|
- python3 /tmp/mkzip.py "$MODULE" "$VERSION"
|
||||||
|
- |
|
||||||
|
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" -X PUT \
|
||||||
"https://git.beatrice.wtf/api/packages/panic.haus/go/upload" \
|
"https://git.beatrice.wtf/api/packages/panic.haus/go/upload" \
|
||||||
-H "Authorization: token $GITEA_TOKEN" \
|
-H "Authorization: token $GITEA_TOKEN" \
|
||||||
-H "Content-Type: application/zip" \
|
-H "Content-Type: application/zip" \
|
||||||
--data-binary "@/tmp/module.zip"
|
--data-binary "@/tmp/module.zip")
|
||||||
|
echo "Upload HTTP $HTTP_CODE"
|
||||||
|
[ "$HTTP_CODE" = "201" ] || exit 1
|
||||||
- echo "Published $MODULE@$VERSION to Gitea package registry"
|
- echo "Published $MODULE@$VERSION to Gitea package registry"
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
|
|||||||
Reference in New Issue
Block a user