mfm/.drone.yml
Glenn Y. Rolland 744ef5daf1
All checks were successful
continuous-integration/drone/push Build is passing
chore: Update Drone CI configuration for package upload process
2024-12-30 00:53:26 +01:00

130 lines
3.8 KiB
YAML

---
kind: pipeline
type: docker
name: default
steps:
- name: build:binary
image: crystallang/crystal:1.11.0-alpine
environment:
PACKAGE_BASENAME: mfm_linux_amd64
volumes:
- name: cache
path: /_cache
commands:
- pwd
# - |
# apt-get update && \
# apt-get install -y \
# cmake g++ \
# libevent-dev libpcre3-dev \
# libyaml-dev liblzma-dev
- shards install
- shards build --production --static
- strip bin/mfm
- ./bin/mfm --version
- mkdir -p /_cache/bin
- cp -r bin/mfm /_cache/bin/$PACKAGE_BASENAME
- name: build:debian
image: debian:bullseye
environment:
PACKAGE_BASENAME: mfm_linux_amd64
volumes:
- name: cache
path: /_cache
commands:
- apt-get update
- apt-get install -y build-essential debhelper devscripts dh-make
- curl -fsSL https://crystal-lang.org/install.sh | bash
- mkdir -p /_cache/debian
- mkdir -p /_cache/bin
- cp -r * /_cache/debian
- cd /_cache/debian
- dpkg-buildpackage -us -uc -d
- mv ../*.deb /_cache/bin
- name: publish:tag
image: alpine
environment:
PACKAGE_UPLOAD_URL: https://code.apps.glenux.net/api/v1/packages/glenux/generic/mfm
RELEASES_URL: https://code.apps.glenux.net/api/v1/repos/glenux/mfm/releases
PACKAGE_BASENAME: mfm_linux_amd64
RELEASE_UPLOAD_TOKEN:
from_secret: RELEASE_UPLOAD_TOKEN
PACKAGE_UPLOAD_TOKEN:
from_secret: PACKAGE_UPLOAD_TOKEN
when:
ref:
include:
- refs/tags/**
volumes:
- name: cache
path: /_cache
commands:
- apk add --update --no-cache curl jq
- env |grep DRONE
# Upload packages
- |
curl -H "Authorization: token $PACKAGE_UPLOAD_TOKEN" \
--upload-file "/_cache/bin/$PACKAGE_BASENAME" \
"$PACKAGE_UPLOAD_URL/$DRONE_TAG/$PACKAGE_BASENAME"
# - |
# for deb in /_cache/bin/*.deb; do
# curl -H "Authorization: token $PACKAGE_UPLOAD_TOKEN" \
# --upload-file "$deb" \
# "$PACKAGE_UPLOAD_URL/$DRONE_TAG/$(basename $deb)"
# done
- |
set -x
curl -X POST \
-H "Authorization: token $RELEASE_UPLOAD_TOKEN" \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d "{\"body\": \"DRAFT\", \"draft\": true, \"name\": \"$DRONE_TAG - DRAFT\", \"prerelease\": false, \"tag_name\": \"$DRONE_TAG\", \"target_commitish\": \"$DRONE_COMMIT_SHA\"}" \
"$RELEASES_URL"
- |
curl -X 'GET' \
-H 'accept: application/json' \
"$RELEASES_URL/tags/$DRONE_TAG"
- |
TAG_ID="$(curl -X 'GET' \
-H 'accept: application/json' \
"$RELEASES_URL/tags/$DRONE_TAG" | jq -r .id)"
echo "TAG_ID=$TAG_ID"
- |
set -x
curl -X POST \
-H "Authorization: token $RELEASE_UPLOAD_TOKEN" \
-H "accept: application/json" \
-H "Content-Type: multipart/form-data" \
-F "attachment=@/_cache/bin/$PACKAGE_BASENAME" \
"$RELEASES_URL/$TAG_ID/assets?name=$PACKAGE_BASENAME"
# - |
# set -x
# for deb in /_cache/bin/*.deb; do
# curl -X POST \
# -H "Authorization: token $RELEASE_UPLOAD_TOKEN" \
# -H "accept: application/json" \
# -H "Content-Type: multipart/form-data" \
# -F "attachment=@$deb" \
# "$RELEASES_URL/$TAG_ID/assets?name=$(basename $deb)"
# done
# FIXME: handle multi-arch
# FIXME: publish only on tags
services:
- name: docker
image: docker:dind
privileged: true
volumes:
- name: dockersock
path: /var/run
volumes:
- name: cache
temp: {}
- name: dockersock
temp: {}
#