ci: Use resource for Gitea package upload
Some checks are pending
test Testing the new resource type
lint/clippy Checking for common mistakes and opportunities for code improvement
build/msvc Build for the target platform: msvc
build/linux Build for the target platform: linux
Some checks are pending
test Testing the new resource type
lint/clippy Checking for common mistakes and opportunities for code improvement
build/msvc Build for the target platform: msvc
build/linux Build for the target platform: linux
This commit is contained in:
parent
6eb3137429
commit
f30dc95385
7 changed files with 113 additions and 80 deletions
|
@ -40,4 +40,4 @@ jobs:
|
|||
pr: ((.:pr))
|
||||
gitea_api_key: ((gitea_api_key))
|
||||
instance_vars:
|
||||
pr: ((.:pr.number))
|
||||
n: ((.:pr.number))
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
---
|
||||
|
||||
# The actual CI pipeline that is run per branch
|
||||
resource_types:
|
||||
- name: gitea-package
|
||||
type: registry-image
|
||||
source:
|
||||
repository: registry.local:5000/gitea-package
|
||||
|
||||
resources:
|
||||
- name: repo
|
||||
|
@ -9,6 +14,14 @@ resources:
|
|||
source:
|
||||
uri: http://forgejo:3000/bitsquid_dt/dtmt
|
||||
branch: ((pr.head.ref))
|
||||
- name: gitea-package
|
||||
type: gitea-package
|
||||
source:
|
||||
access_token: ((gitea_api_key))
|
||||
url: http://forgejo:3000
|
||||
owner: concourse
|
||||
type: generic
|
||||
name: dtmt
|
||||
|
||||
jobs:
|
||||
- name: clippy
|
||||
|
@ -16,6 +29,7 @@ jobs:
|
|||
- get: repo
|
||||
trigger: true
|
||||
- load_var: ref
|
||||
format: trim
|
||||
file: repo/.git/ref
|
||||
- task: check
|
||||
file: repo/.ci/tasks/clippy.yml
|
||||
|
@ -28,35 +42,61 @@ jobs:
|
|||
- get: repo
|
||||
trigger: true
|
||||
- load_var: ref
|
||||
format: trim
|
||||
file: repo/.git/ref
|
||||
- task: build
|
||||
file: repo/.ci/tasks/build.yml
|
||||
vars:
|
||||
target: msvc
|
||||
output: artifact
|
||||
ref: ((.:ref))
|
||||
pr: ((pr))
|
||||
gitea_url: http://forgejo:3000
|
||||
gitea_api_key: ((gitea_api_key))
|
||||
- load_var: version_number
|
||||
reveal: true
|
||||
file: artifact/version
|
||||
- put: package
|
||||
resource: gitea-package
|
||||
no_get: true
|
||||
inputs:
|
||||
- artifact
|
||||
params:
|
||||
version: ((.:version_number))
|
||||
fail_fast: true
|
||||
override: true
|
||||
globs:
|
||||
- artifact/dtmt
|
||||
- artifact/dtmm
|
||||
- artifact/*.exe
|
||||
|
||||
- name: build-linux
|
||||
plan:
|
||||
- get: repo
|
||||
trigger: true
|
||||
- load_var: ref
|
||||
reveal: true
|
||||
file: repo/.git/ref
|
||||
- task: build
|
||||
file: repo/.ci/tasks/build.yml
|
||||
vars:
|
||||
target: linux
|
||||
output: artifact
|
||||
ref: ((.:ref))
|
||||
pr: ((pr))
|
||||
gitea_url: http://forgejo:3000
|
||||
gitea_api_key: ((gitea_api_key))
|
||||
- task: upload
|
||||
file: repo/.ci/tasks/upload.yml
|
||||
vars:
|
||||
input: artifact
|
||||
pr: ((.:pr))
|
||||
gitea_api_key: ((gitea_api_key))
|
||||
gitea_user: bitsquid_dt
|
||||
gitea_url: http://forgejo:3000
|
||||
- load_var: version_number
|
||||
reveal: true
|
||||
file: artifact/version
|
||||
- put: package
|
||||
resource: gitea-package
|
||||
no_get: true
|
||||
inputs:
|
||||
- artifact
|
||||
params:
|
||||
version: ((.:version_number))
|
||||
fail_fast: true
|
||||
override: true
|
||||
globs:
|
||||
- artifact/dtmt
|
||||
- artifact/dtmm
|
||||
- artifact/*.exe
|
||||
|
|
|
@ -1,25 +1,48 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -eux
|
||||
set -eu
|
||||
|
||||
if [ -n "$OUTPUT" ]; then
|
||||
OUTPUT="$PWD/$OUTPUT"
|
||||
else
|
||||
OUTPUT=$(mktemp -d)
|
||||
fi
|
||||
|
||||
title() {
|
||||
printf "\033[1m%s\033[0m\n" "$1"
|
||||
}
|
||||
|
||||
if [ -n "${PR:-}" ]; then
|
||||
title "PR: $(echo "$PR" | jq '.number') - $(echo "$PR" | jq '.title')"
|
||||
ref="pr-$(echo "$PR" | jq '.number')-$(git rev-parse --short HEAD 2>/dev/null || echo 'manual')"
|
||||
else
|
||||
ref=$(git describe --tags)
|
||||
fi
|
||||
|
||||
title "Version is '$ref'"
|
||||
echo "$ref" > "$OUTPUT/version"
|
||||
|
||||
cd "repo"
|
||||
case "$TARGET" in
|
||||
msvc)
|
||||
cp /src/*.lib ./lib/oodle/
|
||||
|
||||
title "Build project for target $TARGET"
|
||||
cargo build --color always --locked --release --target x86_64-pc-windows-msvc -Zbuild-std
|
||||
|
||||
if [ -d "$OUTPUT" ]; then
|
||||
title "Install artifacts"
|
||||
install -t "$OUTPUT/" target/x86_64-pc-windows-msvc/release/dtmt.exe
|
||||
install -t "$OUTPUT/" target/x86_64-pc-windows-msvc/release/dtmm.exe
|
||||
fi
|
||||
;;
|
||||
linux)
|
||||
cp /src/*.a ./lib/oodle/
|
||||
|
||||
title "Build project for target $TARGET"
|
||||
cargo build --color always --locked --profile release-lto
|
||||
|
||||
if [ -d "$OUTPUT" ]; then
|
||||
install -t "$OUTPUT/" target/release/dtmt
|
||||
install -t "$OUTPUT/" target/release/dtmm
|
||||
fi
|
||||
title "Install artifacts"
|
||||
install -t "$OUTPUT/" target/release-lto/dtmt
|
||||
install -t "$OUTPUT/" target/release-lto/dtmm
|
||||
;;
|
||||
*)
|
||||
echo "Env var 'TARGET' must either be 'msvc' or 'linux'. Got '$TARGET'." >&2
|
||||
|
|
|
@ -13,7 +13,7 @@ inputs:
|
|||
- name: repo
|
||||
|
||||
outputs:
|
||||
- name: artifacts
|
||||
- name: artifact
|
||||
|
||||
caches:
|
||||
- path: repo/target
|
||||
|
@ -24,12 +24,12 @@ params:
|
|||
TARGET: ((target))
|
||||
GITEA_API_KEY: ((gitea_api_key))
|
||||
REF: ((ref))
|
||||
OUTPUT: artifacts
|
||||
PR: ((pr))
|
||||
OUTPUT: artifact
|
||||
|
||||
run:
|
||||
path: .ci/util/run.sh
|
||||
dir: repo
|
||||
path: repo/.ci/util/run.sh
|
||||
args:
|
||||
- .ci/tasks/build.sh
|
||||
- repo/.ci/tasks/build.sh
|
||||
- build/((target))
|
||||
- "Build for the target platform: ((target))"
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -eu
|
||||
|
||||
artifacts="$PWD/artifacts"
|
||||
repo="$PWD/repo"
|
||||
|
||||
base_url="${GITEA_URL}/api/packages/${GITEA_USER}/generic"
|
||||
|
||||
cd "$repo"
|
||||
|
||||
if [ -n "$PR" ]; then
|
||||
echo "PR: $(echo "$PR" | jq '.number') - $(echo "$PR" | jq '.title')"
|
||||
ref="pr-$(echo "$PR" | jq '.number')-$(git rev-parse --short HEAD 2>/dev/null || echo 'manual')"
|
||||
else
|
||||
ref=$(git describe --tags)
|
||||
fi
|
||||
|
||||
echo "ref: $ref"
|
||||
|
||||
# TODO: If this is a tag, check the tag name to determine which
|
||||
# binary was affected and only upload that.
|
||||
for f in dtmt dtmt.exe dtmm dtmm.exe; do
|
||||
if [ -f "$artifacts/$f" ]; then
|
||||
url="$base_url/$(basename -s .exe $f)/$ref/$f"
|
||||
curl -i -X 'PUT' \
|
||||
--user "concourse:$GITEA_API_KEY" \
|
||||
--upload-file "$artifacts/$f" \
|
||||
"$url"
|
||||
fi
|
||||
done
|
|
@ -1,24 +0,0 @@
|
|||
# yaml-language-server: $schema=https://raw.githubusercontent.com/cappyzawa/concourse-pipeline-jsonschema/master/concourse_jsonschema.json#/definitions/TaskConfig
|
||||
---
|
||||
platform: linux
|
||||
|
||||
image_resource:
|
||||
name: python-script
|
||||
type: registry-image
|
||||
source:
|
||||
repository: registry.local:5000/python-script
|
||||
tag: latest
|
||||
|
||||
inputs:
|
||||
- name: repo
|
||||
- name: ((input))
|
||||
|
||||
params:
|
||||
CI: "true"
|
||||
GITEA_API_KEY: ((gitea_api_key))
|
||||
GITEA_URL: ((gitea_url))
|
||||
GITEA_USER: ((user))
|
||||
PR: ((pr))
|
||||
|
||||
run:
|
||||
path: repo/.ci/tasks/upload.sh
|
25
Justfile
25
Justfile
|
@ -1,3 +1,5 @@
|
|||
fly_target := "main"
|
||||
|
||||
ci-build: ci-build-msvc ci-build-linux
|
||||
|
||||
ci-build-msvc:
|
||||
|
@ -25,3 +27,26 @@ ci-image-linux:
|
|||
docker build -t dtmt-ci-base-linux -f .ci/image/Dockerfile.linux .ci/image
|
||||
docker tag dtmt-ci-base-linux registry.sclu1034.dev/dtmt-ci-base-linux
|
||||
docker push registry.sclu1034.dev/dtmt-ci-base-linux
|
||||
|
||||
set-base-pipeline:
|
||||
fly -t ((fly_target)) set-pipeline \
|
||||
--pipeline dtmt-prs \
|
||||
--config .ci/pipelines/base-pipeline.yml \
|
||||
-v gitea_api_key=${GITEA_API_KEY} \
|
||||
-v owner=bitsquid_dt \
|
||||
-v repo=dtmt
|
||||
|
||||
set-pr-pipeline pr:
|
||||
curl \
|
||||
-H "Authorization: ${GITEA_API_KEY}" \
|
||||
-H 'Accept: application/json' \
|
||||
'https://git.sclu1034.dev/api/v1/repos/bitsquid_dt/dtmt/pulls/{{pr}}' \
|
||||
| yq -y '.' - > 'pr-{{pr}}.yaml'
|
||||
fly -t main set-pipeline \
|
||||
--pipeline dtmt-pr \
|
||||
--config .ci/pipelines/pr.yml \
|
||||
-v gitea_api_key=${GITEA_API_KEY} \
|
||||
-i n={{pr}} \
|
||||
-y branch="$(yq -y '.head.ref' 'pr-{{pr}}.yaml')" \
|
||||
-y pr="$(cat 'pr-{{pr}}.yaml')"
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue