Compare commits

..

24 Commits

Author SHA1 Message Date
4fe437d3b5 feat(ci): Switched to odit build image for cache
All checks were successful
ci/woodpecker/push/build Pipeline was successful
2023-11-24 11:28:55 +01:00
060d4761f9 Added additional cli output
All checks were successful
ci/woodpecker/push/build Pipeline was successful
2023-11-10 14:56:09 +01:00
b1dfe5024f Removed unused git variables
All checks were successful
ci/woodpecker/push/build Pipeline was successful
2023-11-10 14:50:54 +01:00
64825a7878 Use new drone ci provided repo name
All checks were successful
ci/woodpecker/push/build Pipeline was successful
2023-11-10 14:46:27 +01:00
5da72ff00e removed unneeded sleep
All checks were successful
ci/woodpecker/push/build Pipeline was successful
2023-11-10 14:41:22 +01:00
b836f78281 sleep
All checks were successful
ci/woodpecker/push/build Pipeline was successful
2023-11-10 14:38:27 +01:00
5b2c3abda8 Removed push that is not used
All checks were successful
ci/woodpecker/push/build Pipeline was successful
2023-11-10 14:34:20 +01:00
5c626f574e Added sleep for debugging
All checks were successful
ci/woodpecker/push/build Pipeline was successful
2023-11-10 14:26:36 +01:00
b7146f8c75 Updated output
All checks were successful
ci/woodpecker/push/build Pipeline was successful
2023-11-10 14:22:18 +01:00
f25083142d Don't fetch via git
All checks were successful
ci/woodpecker/push/build Pipeline was successful
2023-11-10 14:16:19 +01:00
c98213cabb Disabled netrc stuff
All checks were successful
ci/woodpecker/push/build Pipeline was successful
2023-11-10 14:07:12 +01:00
39be548404 Switched over to woodpecker variable names
All checks were successful
ci/woodpecker/push/build Pipeline was successful
2023-11-10 14:04:00 +01:00
d870961563 Disable netrc (experimental)
All checks were successful
ci/woodpecker/push/build Pipeline was successful
2023-11-07 19:45:31 +01:00
58c4f67ada Switch to woodpecker
All checks were successful
ci/woodpecker/push/build Pipeline was successful
2023-11-04 15:35:30 +01:00
97df9f5595 feat(api): Fail on curl server fails
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-12 12:38:48 +02:00
df2a3e143f chore(deps): changelogen@1.0.0
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-11 22:08:33 +02:00
0042f118b9 Added sample values
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-11 22:03:20 +02:00
4f19015123 feat(release): You can now set the gitea release as a draft and prerelease 2023-05-11 22:02:49 +02:00
562a7542f3 fix(git): Switched from taggerdate to creatordate for latest recognition
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-11 19:26:07 +02:00
0a2628d5c6 Pinned changelogen version
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-10 21:12:32 +02:00
984e276c27 Falling back to empty version prefix
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-10 20:43:02 +02:00
c8a1cec4f9 Added additional echo
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-10 20:39:04 +02:00
0da154e61e Moved formatted generation down
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-10 20:36:34 +02:00
b65ada0689 also use prefix in normal body 2023-05-10 20:36:09 +02:00
4 changed files with 58 additions and 67 deletions

View File

@@ -1,35 +0,0 @@
---
kind: secret
name: docker_username
get:
path: odit-registry-builder
name: username
---
kind: secret
name: docker_password
get:
path: odit-registry-builder
name: password
---
kind: pipeline
type: kubernetes
name: build:latest
steps:
- name: docker release
image: registry.odit.services/library/drone-kaniko
settings:
username:
from_secret: docker_username
password:
from_secret: docker_password
repo: library/drone-changelogger
tags:
- latest
registry: registry.odit.services
trigger:
branch:
- main
event:
- push

21
.woodpecker/build.yml Normal file
View File

@@ -0,0 +1,21 @@
steps:
- name: build latest
image: registry.odit.services/library/docker-buildx
settings:
repo: registry.odit.services/library/drone-changelogger
tags:
- latest
registry: registry.odit.services
platforms: linux/amd64,linux/arm64
cache_from:
- 'type=registry\\,ref=registry.odit.services/library/drone-changelogger:dev'
- 'type=registry\\,ref=registry.odit.services/library/drone-changelogger:cache'
cache_to:
- 'type=registry\\,ref=registry.odit.services/library/drone-changelogger:cache\\,mode=max\\,image-manifest=true\\,oci-mediatypes=true'
username:
from_secret: odit-registry-builder-username
password:
from_secret: odit-registry-builder-password
when:
branch: main
event: push

View File

@@ -12,6 +12,8 @@ Uses changelogen for changelog generation, is able to create gitea releases and
## Settings 🛠️
* `GITEA_DOMAIN`: Domain name of your gitea server - if not set release creation get's skipped
* `GITEA_APIKEY`: Api token for a gitea user that has the privileges to create releases in your repo
* `GITEA_DRAFT`: Mark gitea release as draft - defaults to false
* `GITEA_PRERELEASE`: Mark gitea release as prerelease - defaults to false
* `MATRIX_SERVER`: The matrix server's domain name - if not set notification sending get's skipped
* `MATRIX_USER`: The matrix user's username
* `MATRIX_PASSWORD`: The matrix user's password
@@ -33,6 +35,8 @@ steps:
GITEA_DOMAIN: git.odit.services
GITEA_APIKEY:
from_secret: gitea_token
GITEA_DRAFT: false
GITEA_PRERELEASE: true
MATRIX_SERVER: matrix.org
MATRIX_USER: "oditservicesbot"
MATRIX_PASSWORD:

View File

@@ -1,59 +1,51 @@
#!/bin/sh
set -euo pipefail
echo "Starting release script"
if [[ ! -z "${DRONE_NETRC_MACHINE}" ]]; then
cat <<EOF > ${HOME}/.netrc
machine ${DRONE_NETRC_MACHINE}
login ${DRONE_NETRC_USERNAME}
password ${DRONE_NETRC_PASSWORD}
EOF
fi
if [[ -z "${DRONE_COMMIT_AUTHOR_NAME}" ]]; then
export DRONE_COMMIT_AUTHOR_NAME=drone
fi
if [[ -z "${DRONE_COMMIT_AUTHOR_EMAIL}" ]]; then
export DRONE_COMMIT_AUTHOR_EMAIL=drone@localhost
fi
export GIT_AUTHOR_NAME=${DRONE_COMMIT_AUTHOR_NAME}
export GIT_AUTHOR_EMAIL=${DRONE_COMMIT_AUTHOR_EMAIL}
export GIT_COMMITTER_NAME=${DRONE_COMMIT_AUTHOR_NAME}
export GIT_COMMITTER_EMAIL=${DRONE_COMMIT_AUTHOR_EMAIL}
git fetch --tags
CURRENTTAG=$(git tag --sort=-taggerdate | head -n 1)
PREVIOUSTAG=$(git tag --sort=-taggerdate | head -n 2 | tail -n 1)
ALLCHANGES=$(npx -y @philippdormann/changelogen@latest --from $PREVIOUSTAG --to $CURRENTTAG --no-output | sed 's/"/\\"/g' | tail -n +6)
FORMATTED_CHANGES=$(echo "# $PLUGIN_VERSION_PREFIX$CURRENTTAG \n $ALLCHANGES" | pandoc -f markdown -t html | sed 's/"/'"'"'/g' | xargs echo -n)
CURRENTTAG=$(git tag --sort=-creatordate | head -n 1)
PREVIOUSTAG=$(git tag --sort=-creatordate | head -n 2 | tail -n 1)
echo "Diff: $PREVIOUSTAG..$CURRENTTAG"
echo "Generating changelog..."
ALLCHANGES=$(npx -y @philippdormann/changelogen@1.0.0 --from $PREVIOUSTAG --to $CURRENTTAG --no-output | sed 's/"/\\"/g' | tail -n +6)
echo "Changelog: $ALLCHANGES"
if [ "${PLUGIN_GITEA_DOMAIN:+set}" = set ]; then
echo "Detected gitea domain, creating release";
if [ "${PLUGIN_GITEA_APIKEY:-null}" = null ]; then
echo "No api key provided";
exit 1;
fi
if [ "${PLUGIN_REPO:-null}" = null ]; then
echo "Falling back to drone repo name";
PLUGIN_REPO=$CI_REPO_NAME
echo "Falling back to ci repo name: ${CI_REPO}";
PLUGIN_REPO=$CI_REPO
fi
if [ "${PLUGIN_GITEA_DRAFT:-null}" = null ]; then
PLUGIN_GITEA_DRAFT=false
fi
if [ "${PLUGIN_GITEA_PRERELEASE:-null}" = null ]; then
PLUGIN_GITEA_PRERELEASE=true
fi
curl --request POST \
--url "https://$PLUGIN_GITEA_DOMAIN/api/v1/repos/$PLUGIN_REPO/releases" \
--header "Content-Type: application/json" \
--header "Authorization: token $PLUGIN_GITEA_APIKEY" \
-f \
--data "{
\"name\": \"$CURRENTTAG\",
\"body\": \"$ALLCHANGES\",
\"draft\": false,
\"draft\": $PLUGIN_GITEA_DRAFT,
\"prerelease\": $PLUGIN_GITEA_PRERELEASE,
\"tag_name\": \"$CURRENTTAG\"
}"
echo "Release created";
fi
if [ "${PLUGIN_MATRIX_SERVER:+set}" = set ]; then
echo "Detected matrix server, sending notification";
echo "Detected matrix server";
if [ "${PLUGIN_MATRIX_USER:-null}" = null ]; then
echo "No matrix username provided";
@@ -71,18 +63,27 @@ if [ "${PLUGIN_MATRIX_SERVER:+set}" = set ]; then
MATRIX_LOGIN=$(curl --request POST \
--url "https://$PLUGIN_MATRIX_SERVER/_matrix/client/r0/login" \
--header "Content-Type: application/json" \
-f \
--data "{
\"type\": \"m.login.password\",
\"user\": \"$PLUGIN_MATRIX_USER\",
\"password\": \"$PLUGIN_MATRIX_PASSWORD\"
}")
MATRIX_TOKEN=$(echo $MATRIX_LOGIN | jq .access_token | sed 's/"//g' )
if [ "${PLUGIN_VERSION_PREFIX:-null}" = null ]; then
echo "Falling back to empty version prefix";
PLUGIN_VERSION_PREFIX=""
fi
FORMATTED_CHANGES=$(echo "# $PLUGIN_VERSION_PREFIX$CURRENTTAG \n $ALLCHANGES" | pandoc -f markdown -t html | sed 's/"/'"'"'/g' | xargs echo -n)
curl --request POST \
--url "https://$PLUGIN_MATRIX_SERVER/_matrix/client/r0/rooms/$PLUGIN_MATRIX_ROOM/send/m.room.message?access_token=$MATRIX_TOKEN" \
--header "Content-Type: application/json" \
-f \
--data "{
\"msgtype\": \"m.text\",
\"body\": \"$(echo "# $CURRENTTAG \n $ALLCHANGES" | xargs echo -n)\",
\"body\": \"$(echo "# $PLUGIN_VERSION_PREFIX$CURRENTTAG \n $ALLCHANGES" | xargs echo -n)\",
\"format\": \"org.matrix.custom.html\",
\"formatted_body\": \"$FORMATTED_CHANGES\"
}"