2023-10-25 12:11:28 +00:00
|
|
|
---
|
|
|
|
kind: pipeline
|
|
|
|
type: docker
|
|
|
|
name: default
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: build:binary
|
|
|
|
image: crystallang/crystal:1.7.3
|
2023-10-25 12:28:54 +00:00
|
|
|
environment:
|
|
|
|
PACKAGE_BASENAME: mfm_linux_amd64
|
2023-10-25 12:11:28 +00:00
|
|
|
volumes:
|
|
|
|
- name: cache
|
|
|
|
path: /_cache
|
|
|
|
commands:
|
|
|
|
- pwd
|
2023-10-25 12:28:54 +00:00
|
|
|
- apt-get update &&
|
|
|
|
apt-get install -y cmake g++ libevent-dev libpcre3-dev libyaml-dev
|
2023-10-25 12:11:28 +00:00
|
|
|
- shards install
|
|
|
|
- shards build --production --static
|
2023-10-25 12:18:07 +00:00
|
|
|
- strip bin/mfm
|
2023-10-25 12:11:28 +00:00
|
|
|
- mkdir -p /_cache/bin
|
2023-10-25 12:28:54 +00:00
|
|
|
- cp -r bin/mfm /_cache/bin/$PACKAGE_BASENAME
|
2023-10-25 12:11:28 +00:00
|
|
|
|
|
|
|
- name: publish:tag
|
2023-10-25 14:23:16 +00:00
|
|
|
image: alpine
|
2023-10-25 12:11:28 +00:00
|
|
|
environment:
|
2023-10-25 14:09:06 +00:00
|
|
|
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
|
2023-10-25 12:18:07 +00:00
|
|
|
PACKAGE_BASENAME: mfm_linux_amd64
|
2023-10-25 14:03:22 +00:00
|
|
|
RELEASE_UPLOAD_TOKEN:
|
|
|
|
from_secret: RELEASE_UPLOAD_TOKEN
|
2023-10-25 12:11:28 +00:00
|
|
|
PACKAGE_UPLOAD_TOKEN:
|
|
|
|
from_secret: PACKAGE_UPLOAD_TOKEN
|
|
|
|
when:
|
|
|
|
ref:
|
|
|
|
include:
|
|
|
|
- refs/tags/**
|
|
|
|
volumes:
|
|
|
|
- name: cache
|
|
|
|
path: /_cache
|
|
|
|
commands:
|
2023-10-25 14:23:16 +00:00
|
|
|
- apk add --update --no-cache curl jq
|
2023-10-25 12:11:28 +00:00
|
|
|
- env |grep DRONE
|
|
|
|
- |
|
|
|
|
curl -H "Authorization: token $PACKAGE_UPLOAD_TOKEN" \
|
2023-10-25 13:24:36 +00:00
|
|
|
--upload-file "/_cache/bin/$PACKAGE_BASENAME" \
|
|
|
|
"$PACKAGE_UPLOAD_URL/$DRONE_TAG/$PACKAGE_BASENAME"
|
|
|
|
- |
|
2023-10-25 14:09:06 +00:00
|
|
|
set -x
|
|
|
|
curl -X POST \
|
2023-10-25 14:11:52 +00:00
|
|
|
-H "Authorization: token $RELEASE_UPLOAD_TOKEN" \
|
2023-10-25 14:03:22 +00:00
|
|
|
-H 'accept: application/json' \
|
|
|
|
-H 'Content-Type: application/json' \
|
2023-10-25 14:05:54 +00:00
|
|
|
-d "{\"body\": \"DRAFT\", \"draft\": true, \"name\": \"$DRONE_TAG - DRAFT\", \"prerelease\": false, \"tag_name\": \"$DRONE_TAG\", \"target_commitish\": \"$DRONE_COMMIT_SHA\"}" \
|
2023-10-25 14:03:22 +00:00
|
|
|
"$RELEASES_URL"
|
2023-10-25 14:23:16 +00:00
|
|
|
- |
|
|
|
|
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"
|
2023-10-25 13:24:36 +00:00
|
|
|
- |
|
2023-10-25 13:35:41 +00:00
|
|
|
set -x
|
2023-10-25 14:03:22 +00:00
|
|
|
curl -X POST \
|
|
|
|
-H "Authorization: token $RELEASE_UPLOAD_TOKEN" \
|
2023-10-25 13:27:55 +00:00
|
|
|
-H "accept: application/json" \
|
|
|
|
-H "Content-Type: multipart/form-data" \
|
|
|
|
-F "attachment=@/_cache/bin/$PACKAGE_BASENAME" \
|
2023-10-25 14:23:16 +00:00
|
|
|
"$RELEASES_URL/$TAG_ID/assets?name=$PACKAGE_BASENAME"
|
2023-10-25 13:24:36 +00:00
|
|
|
|
2023-10-25 12:11:28 +00:00
|
|
|
|
|
|
|
# FIXME: handle multi-arch
|
|
|
|
# FIXME: publish only on tags
|
|
|
|
|
|
|
|
volumes:
|
|
|
|
- name: cache
|
|
|
|
temp: {}
|
|
|
|
#
|