diff --git a/.woodpecker/release.yaml b/.woodpecker/release.yaml new file mode 100644 index 0000000..fb67128 --- /dev/null +++ b/.woodpecker/release.yaml @@ -0,0 +1,45 @@ +# 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 ] diff --git a/.woodpecker/style.yaml b/.woodpecker/style.yaml index a5abd2c..f1288ef 100644 --- a/.woodpecker/style.yaml +++ b/.woodpecker/style.yaml @@ -4,7 +4,7 @@ # - https://black.readthedocs.io/en/stable/usage_and_configuration/black_docker_image.html when: - event: [push, pull_request] + event: [push, pull_request, tag] steps: - name: ruff