infra-rebuild/.woodpecker/release.yaml
June 8295926cf9
Some checks failed
ci/woodpecker/push/style Pipeline was successful
ci/woodpecker/tag/style Pipeline failed
ci/woodpecker/tag/release Pipeline was successful
ci test
2024-06-23 21:06:12 +02:00

46 lines
1.9 KiB
YAML

# Links & Resources
# - https://hatch.pypa.io/latest/install/#pipx
# - https://woodpecker-ci.org/plugins/Release
# - https://forgejo.org/docs/latest/user/api-usage/
# - https://git.hamburg.ccc.de/api/swagger#/repository
when:
event: tag
# depends_on:
# - style
workspace:
base: /base
path: src
steps:
- name: build
image: debian
commands:
- apt-get update
- apt-get install -y pipx
- pipx install hatch
- /root/.local/bin/hatch build
- name: release
image: debian
commands:
- echo $SHELL
- apt-get update
- apt-get install -y git jq curl
# Directory for storing release information and request data.
- mkdir /base/release
# Get the release notes from the git tag.
- git tag -l --format='%(contents)' $CI_COMMIT_TAG > /base/release/release_notes
# Data for the release creation request.
- "echo '{\"body\": ' > /base/release/create_release_request_data.json"
- jq -Rs . /base/release/release_notes >> /base/release/create_release_request_data.json
- "echo ', \"name\": \"CI_COMMIT_TAG\", \"tag_name\": \"CI_COMMIT_TAG\"}' >> /base/release/create_release_request_data.json"
- "sed -i \"s/CI_COMMIT_TAG/$CI_COMMIT_TAG/g\" /base/release/create_release_request_data.json"
- cat /base/release/create_release_request_data.json
# Create the release.
- "curl -f --header \"Authorization: token $FORGEJO_RELEASE_ACCESS_TOKEN\" -X POST --json @/base/release/create_release_request_data.json \"$CI_FORGE_URL/api/v1/repos/$CI_REPO/releases\" > /base/release/create_release_response.json"
# Upload the release assets.
- "for FILE in /base/src/dist/*; do curl -f --header \"Authorization: token $FORGEJO_RELEASE_ACCESS_TOKEN\" -X POST -F \"attachment=@$FILE\" \"$CI_FORGE_URL/api/v1/repos/$CI_REPO/releases/$(jq -r .id /base/release/create_release_response.json)/assets\"; done"
secrets: [ FORGEJO_RELEASE_ACCESS_TOKEN ]