diff --git a/ci/pipeline.yml b/ci/pipeline.yml index 2d8381d..7bb9bfc 100644 --- a/ci/pipeline.yml +++ b/ci/pipeline.yml @@ -23,6 +23,7 @@ groups: jobs: - check-code - release + - publish-to-crates - set-dev-version jobs: @@ -63,34 +64,127 @@ jobs: - name: repo run: path: pipeline-tasks/ci/tasks/update-repo.sh - - task: publish-to-crates + - in_parallel: + - task: build-windows-release + privileged: true + config: + platform: linux + image_resource: + type: registry-image + source: + username: #@ data.values.osxcross_docker_username + password: #@ data.values.osxcross_docker_password + repository: #@ data.values.osxcross_repository + inputs: + - name: version + - name: pipeline-tasks + - name: repo + outputs: + - name: x86_64-pc-windows-gnu + caches: + - path: cargo-home + - path: cargo-target-dir + params: + TARGET: x86_64-pc-windows-gnu + OUT: x86_64-pc-windows-gnu + run: + path: pipeline-tasks/ci/tasks/build-release.sh + - task: build-osx-release + privileged: true + config: + platform: linux + image_resource: + type: registry-image + source: + username: #@ data.values.osxcross_docker_username + password: #@ data.values.osxcross_docker_password + repository: #@ data.values.osxcross_repository + inputs: + - name: version + - name: pipeline-tasks + - name: repo + outputs: + - name: x86_64-apple-darwin + caches: + - path: cargo-home + - path: cargo-target-dir + params: + TARGET: x86_64-apple-darwin + OUT: x86_64-apple-darwin + run: + path: pipeline-tasks/ci/tasks/build-release.sh + - task: build-static-release + privileged: true + config: + platform: linux + image_resource: + type: registry-image + source: { repository: clux/muslrust, tag: stable } + inputs: + - name: version + - name: pipeline-tasks + - name: repo + outputs: + - name: x86_64-unknown-linux-musl + caches: + - path: cargo-home + - path: cargo-target-dir + params: + TARGET: x86_64-unknown-linux-musl + OUT: x86_64-unknown-linux-musl + run: + path: pipeline-tasks/ci/tasks/build-release.sh + - task: prep-github-release config: - image_resource: #@ rust_task_image_config() + image_resource: #@ release_task_image_config() platform: linux inputs: + - name: x86_64-pc-windows-gnu + - name: x86_64-apple-darwin + - name: x86_64-unknown-linux-musl - name: version - name: pipeline-tasks - - name: repo - params: - CRATES_API_TOKEN: #@ data.values.crates_api_token - caches: - - path: cargo-home - - path: cargo-target-dir + - name: artifacts + outputs: + - name: artifacts run: - path: pipeline-tasks/ci/tasks/publish-to-crates.sh + path: pipeline-tasks/ci/tasks/prep-github-release.sh - put: repo params: tag: artifacts/gh-release-tag repository: repo merge: true - - put: version - params: - file: version/version - put: gh-release params: name: artifacts/gh-release-name tag: artifacts/gh-release-tag body: artifacts/gh-release-notes.md + globs: [artifacts/binaries/*] + - put: version + params: + file: version/version + +- name: publish-to-crates + plan: + - in_parallel: + - { get: repo, passed: [release], trigger: true } + - get: pipeline-tasks + - get: version + - task: publish-to-crates + config: + image_resource: #@ rust_task_image_config() + platform: linux + inputs: + - name: version + - name: pipeline-tasks + - name: repo + params: + CRATES_API_TOKEN: #@ data.values.crates_api_token + caches: + - path: cargo-home + - path: cargo-target-dir + run: + path: pipeline-tasks/ci/tasks/publish-to-crates.sh - name: set-dev-version plan: diff --git a/ci/tasks/build-release.sh b/ci/tasks/build-release.sh new file mode 100755 index 0000000..9778c06 --- /dev/null +++ b/ci/tasks/build-release.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +set -eu + +VERSION="" +if [[ -f version/version ]];then + VERSION="$(cat version/version)" +fi + +REPO=${REPO:-repo} +BINARY=bria +OUT=${OUT:-none} +WORKSPACE="$(pwd)" + +export CARGO_HOME="$(pwd)/cargo-home" +export CARGO_TARGET_DIR="$(pwd)/cargo-target-dir" + +[ -f /workspace/.cargo/config ] && cp /workspace/.cargo/config ${CARGO_HOME}/config + +pushd ${REPO} + +set -x + +make build-${TARGET}-release + +cd ${CARGO_TARGET_DIR}/${TARGET}/release +OUT_DIR="${BINARY}-${TARGET}-${VERSION}" +rm -rf "${OUT_DIR}" || true +mkdir "${OUT_DIR}" +mv ./${BINARY} ${OUT_DIR} +tar -czvf ${OUT_DIR}.tar.gz ${OUT_DIR} + +mv ${OUT_DIR}.tar.gz ${WORKSPACE}/${OUT}/ diff --git a/ci/tasks/prep-github-release.sh b/ci/tasks/prep-github-release.sh new file mode 100755 index 0000000..7ba6152 --- /dev/null +++ b/ci/tasks/prep-github-release.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -eu + +mkdir artifacts/binaries + +mv x86_64-pc-windows-gnu/* artifacts/binaries +mv x86_64-apple-darwin/* artifacts/binaries +mv x86_64-unknown-linux-musl/* artifacts/binaries + +for file in artifacts/binaries/*; do + if [ -f "$file" ]; then + sha256sum "$file" > "$file".sha256 + fi +done + diff --git a/ci/values.yml b/ci/values.yml index b9bb81c..1ca4b51 100644 --- a/ci/values.yml +++ b/ci/values.yml @@ -18,3 +18,7 @@ crates_api_token: ((crates.token)) slack_channel: galoy-cli-github slack_username: concourse slack_webhook_url: ((addons-slack.api_url)) + +osxcross_docker_username: ((osxcross-image.username)) +osxcross_docker_password: ((osxcross-image.password)) +osxcross_repository: ((osxcross-image.repository))