vieter/.woodpecker/build.yml

74 lines
2.0 KiB
YAML
Raw Permalink Normal View History

2022-09-15 13:42:49 +02:00
variables:
- &vlang_image 'git.rustybever.be/vieter/vlang:5d4c9dc9fc11bf8648541c934adb64f27cb94e37-alpine3.17'
2022-09-15 13:42:49 +02:00
matrix:
PLATFORM:
- 'linux/amd64'
- 'linux/arm64'
2022-01-15 15:30:09 +01:00
platform: ${PLATFORM}
2022-01-13 15:29:43 +01:00
2022-01-13 13:40:33 +01:00
pipeline:
install-modules:
2022-09-15 13:42:49 +02:00
image: *vlang_image
2022-01-22 22:12:30 +01:00
pull: true
2022-01-13 13:40:33 +01:00
commands:
- export VMODULES=$PWD/.vmodules
- 'cd src && v install'
when:
event: [push, pull_request]
debug:
2022-09-15 13:42:49 +02:00
image: *vlang_image
commands:
- export VMODULES=$PWD/.vmodules
- make
2022-01-22 22:18:19 +01:00
when:
event: [pull_request]
branch:
exclude: [main]
2022-01-13 13:40:33 +01:00
prod:
2022-09-15 13:42:49 +02:00
image: *vlang_image
2022-01-14 18:32:00 +01:00
environment:
- LDFLAGS=-lz -lbz2 -llzma -lexpat -lzstd -llz4 -lsqlite3 -static
2022-01-13 13:40:33 +01:00
commands:
- export VMODULES=$PWD/.vmodules
# Apparently this -D is *very* important
- CFLAGS='-DGC_THREADS=1' make prod
2022-01-22 19:29:01 +01:00
# Make sure the binary is actually statically built
2022-01-14 20:43:11 +01:00
- readelf -d pvieter
2022-01-14 21:50:43 +01:00
- du -h pvieter
2022-01-14 20:43:11 +01:00
- '[ "$(readelf -d pvieter | grep NEEDED | wc -l)" = 0 ]'
2022-01-22 19:01:46 +01:00
# This removes so much, it's amazing
- strip -s pvieter
- du -h pvieter
2022-01-22 22:17:38 +01:00
when:
event: [push, pull_request]
2022-01-22 19:01:46 +01:00
upload:
2022-09-15 13:42:49 +02:00
image: *vlang_image
2022-01-22 19:01:46 +01:00
secrets: [ s3_username, s3_password ]
commands:
# https://gist.github.com/JustinTimperio/7c7115f87b775618637d67ac911e595f
- export URL=s3.rustybever.be
2022-01-22 19:30:46 +01:00
- export DATE="$(date -R --utc)"
- export CONTENT_TYPE='application/zstd'
2022-02-22 18:42:09 +01:00
- export OBJ_PATH="/vieter/commits/$CI_COMMIT_SHA/vieter-$(echo '${PLATFORM}' | sed 's:/:-:g')"
2022-01-22 19:26:52 +01:00
- export SIG_STRING="PUT\n\n$CONTENT_TYPE\n$DATE\n$OBJ_PATH"
2023-01-18 18:10:47 +01:00
- export SIGNATURE="$(echo -en $SIG_STRING | openssl dgst -sha1 -hmac $S3_PASSWORD -binary | base64)"
2022-02-22 18:42:09 +01:00
- >
curl
--silent
--fail
2022-02-22 18:42:09 +01:00
-XPUT
-T pvieter
-H "Host: $URL"
-H "Date: $DATE"
-H "Content-Type: $CONTENT_TYPE"
-H "Authorization: AWS $S3_USERNAME:$SIGNATURE"
https://$URL$OBJ_PATH
2022-01-22 22:17:38 +01:00
when:
event: [push, pull_request]