Compare commits

...

48 Commits
0.2.2 ... main

Author SHA1 Message Date
964ea60e55 chore: bump 0.12.0 → 0.13.0 [CI SKIP]
All checks were successful
continuous-integration/drone/tag Build is passing
2024-10-25 16:16:43 +00:00
2386e278c7 Merge branch 'main' of https://gitea.dikurium.ch/InnoPeak/drone-gitea-release into main
Some checks failed
continuous-integration/drone/push Build is failing
2024-10-25 18:16:24 +02:00
66de41874d feat: use time.Time.Before() instead of Sub() 2024-10-25 18:16:24 +02:00
9aace7aa2b chore: bump 0.11.1 → 0.12.0 [CI SKIP]
All checks were successful
continuous-integration/drone/tag Build is passing
2024-10-25 16:14:51 +00:00
6c787535a8 feat: use tagger.when to find latest tag
Some checks failed
continuous-integration/drone/push Build is failing
2024-10-25 18:14:25 +02:00
e65c52c67c chore: bump 0.11.0 → 0.11.1 [CI SKIP]
All checks were successful
continuous-integration/drone/tag Build is passing
2024-07-11 17:54:57 +02:00
d19022dad8 fix: 🐛 append newline after success message, use logger [CI SKIP] 2024-07-11 17:54:33 +02:00
2daf8b0d53 chore: bump 0.10.1 → 0.11.0 [CI SKIP]
All checks were successful
continuous-integration/drone/tag Build is passing
2024-07-11 15:34:11 +00:00
d9f25a2613 Merge branch 'main' of https://gitea.dikurium.ch/InnoPeak/drone-gitea-release into main
Some checks failed
continuous-integration/drone/push Build is failing
2024-07-11 17:33:48 +02:00
b2c43a5f3d feat: use log.textformatter 2024-07-11 17:33:47 +02:00
1c9f839870 chore: bump 0.10.0 → 0.10.1 [CI SKIP]
All checks were successful
continuous-integration/drone/tag Build is passing
2024-07-11 15:26:02 +00:00
76e800c9d4 Merge branch 'main' of https://gitea.dikurium.ch/InnoPeak/drone-gitea-release into main
Some checks failed
continuous-integration/drone/push Build is failing
2024-07-11 17:25:35 +02:00
fe6812860e fix: revert: fix: 🐛 use latest instead of last (oldest) tag
- Add logs
2024-07-11 17:25:35 +02:00
8ff9355fcf chore: bump 0.9.0 → 0.10.0 [CI SKIP]
All checks were successful
continuous-integration/drone/tag Build is passing
2024-07-11 15:09:55 +00:00
913e80c62b Merge branch 'main' of https://gitea.dikurium.ch/InnoPeak/drone-gitea-release into main
Some checks failed
continuous-integration/drone/push Build is failing
2024-07-11 17:09:36 +02:00
cecbbddd07 feat: 🔊 add logs 2024-07-11 17:09:36 +02:00
30fafd87cd chore: bump 0.8.1 → 0.9.0 [CI SKIP]
All checks were successful
continuous-integration/drone/tag Build is passing
2024-07-11 14:57:20 +00:00
3f0e9dd908 Merge branch 'main' of https://gitea.dikurium.ch/InnoPeak/drone-gitea-release into main
All checks were successful
continuous-integration/drone/push Build is passing
2024-07-11 16:57:03 +02:00
f954801b4e feat: add support for adaptive cards 2024-07-11 16:57:02 +02:00
65beb47d43 chore: bump 0.8.0 → 0.8.1 [CI SKIP]
All checks were successful
continuous-integration/drone/tag Build is passing
2024-07-11 14:55:38 +00:00
a7f7cfbc65 fix: 🐛 use latest instead of last (oldest) tag
All checks were successful
continuous-integration/drone/push Build is passing
2024-07-11 16:55:20 +02:00
aca8272527 chore: bump 0.7.0 → 0.8.0 [CI SKIP]
All checks were successful
continuous-integration/drone/tag Build is passing
2024-07-03 12:16:58 +00:00
bc99681992 Merge branch 'main' of https://gitea.dikurium.ch/InnoPeak/drone-gitea-release into main
All checks were successful
continuous-integration/drone/push Build is passing
2024-07-03 14:16:41 +02:00
e11f467042 feat: add git username and password options for http 2024-07-03 14:16:40 +02:00
0dd91c5ce7 chore: bump 0.6.0 → 0.7.0 [CI SKIP]
All checks were successful
continuous-integration/drone/tag Build is passing
2024-07-03 08:55:12 +00:00
0d7cc87b37 feat: output release url on success
All checks were successful
continuous-integration/drone/push Build is passing
2024-07-03 10:54:51 +02:00
556122121b ci: 💚 exit 0 if error in cz bump
All checks were successful
continuous-integration/drone/push Build is passing
2024-06-27 16:33:06 +02:00
e9b1290802 Merge branch 'main' of https://gitea.dikurium.ch/InnoPeak/drone-gitea-release
Some checks failed
continuous-integration/drone/push Build is failing
2024-06-27 16:30:59 +02:00
94399be7e5 ci: 💚 generate current changelog in correct file 2024-06-27 16:30:58 +02:00
eaa00bf4f5 chore: bump 0.5.1 → 0.6.0 [CI SKIP]
All checks were successful
continuous-integration/drone/tag Build is passing
2024-06-27 14:20:32 +00:00
cff062a9b0 Merge branch 'main' of https://gitea.dikurium.ch/InnoPeak/drone-gitea-release
Some checks failed
continuous-integration/drone/push Build is failing
2024-06-27 16:20:14 +02:00
7e02953285 feat: add error handling to fetching git tags if none found 2024-06-27 16:20:14 +02:00
dd01ea4397 chore: bump 0.5.0 → 0.5.1 [CI SKIP]
All checks were successful
continuous-integration/drone/tag Build is passing
2024-06-27 14:13:41 +00:00
643cf127a6 fix: 🐛 bump version to 0.5.1
Some checks failed
continuous-integration/drone/push Build is failing
2024-06-27 16:13:17 +02:00
7b29d479a2 chore: bump 0.4.0 → 0.5.0 [CI SKIP]
All checks were successful
continuous-integration/drone/tag Build is passing
2024-06-27 14:08:45 +00:00
2771371cdf feat: use go-git instead of native Git client to fetch latest tag
Some checks failed
continuous-integration/drone/push Build is failing
2024-06-27 16:08:27 +02:00
6bfb898540 chore: bump 0.3.2 → 0.4.0 [CI SKIP]
All checks were successful
continuous-integration/drone/tag Build is passing
2024-06-26 14:09:36 +00:00
3625bbe90c feat: add option to fetch git tags when getting latest
Some checks failed
continuous-integration/drone/push Build is failing
2024-06-26 16:09:18 +02:00
925bfe59e6 ci: 💚 fix gitea url
Some checks failed
continuous-integration/drone/push Build is failing
2024-06-26 16:04:23 +02:00
6a5acd3a55 chore: bump 0.3.1 → 0.3.2 [CI SKIP]
All checks were successful
continuous-integration/drone/tag Build is passing
2024-06-25 14:08:59 +00:00
90a131f7bb Merge branch 'main' of https://gitea.dikurium.ch/InnoPeak/drone-gitea-release
Some checks failed
continuous-integration/drone/push Build is failing
2024-06-25 16:08:39 +02:00
ded82eb41f fix: 💚 set use_latest_git_tag to true 2024-06-25 16:08:39 +02:00
686b8b2c18 chore: bump 0.3.0 → 0.3.1 [CI SKIP]
All checks were successful
continuous-integration/drone/tag Build is passing
2024-06-25 14:06:02 +00:00
a56b978462 fix: 🐛 add git to Dockerfile
Some checks failed
continuous-integration/drone/push Build is failing
2024-06-25 16:05:44 +02:00
b2a7b1916e chore: bump 0.2.1 → 0.3.0 [CI SKIP]
All checks were successful
continuous-integration/drone/tag Build is passing
2024-06-25 13:30:22 +00:00
ceb8a8bc8e ci: 👷 handle changelog failure gracefully
Some checks failed
continuous-integration/drone/push Build is failing
2024-06-25 15:30:04 +02:00
3509a5c98f feat: add skip_if_no_notes_file setting 2024-06-25 15:29:33 +02:00
8a5a2b85cf ci: 👷 remove main branch from tag trigger
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/tag Build is passing
2024-06-25 15:17:25 +02:00
11 changed files with 468 additions and 50 deletions

View File

@ -12,15 +12,14 @@ steps:
- git config --global --add --bool push.autoSetupRemote true
- git fetch --tags
- pip install -U Commitizen
- cz bump --annotated-tag --yes
- cz bump --annotated-tag --yes || (echo "An error occured while bumping the tag." && exit 0)
- git push --follow-tags
- cz changelog $(cz version -p) > CZ_CURRENT_CHANGELOG.md
- cz changelog $(cz version -p) --file-name CZ_CURRENT_CHANGELOG.md || echo "An error occured while generating the changelog."
environment:
GIT_USERNAME:
from_secret: git_username
GIT_PASSWORD:
from_secret: git_password
failure: ignore
- name: publish Docker image
image: plugins/docker
settings:
@ -31,19 +30,19 @@ steps:
from_secret: docker_username
password:
from_secret: docker_password
- image: gitea.dikurium.ch/innopeak/drone-gitea-release
- image: gitea.dikurium.ch/innopeak/drone-gitea-release:0.7
name: create release
settings:
gitea_password:
from_secret: git_password
gitea_url: gitea.dikurium.ch
gitea_url: https://gitea.dikurium.ch
gitea_username:
from_secret: git_username
notes_file: CZ_CURRENT_CHANGELOG.md
owner: innopeak
repo: drone-gitea-release
depends_on:
- bump tag
skip_if_no_notes_file: true
use_latest_git_tag: true
trigger:
branch:
@ -68,7 +67,5 @@ steps:
from_secret: docker_password
trigger:
branch:
- main
event:
- tag

25
.gitignore vendored Normal file
View File

@ -0,0 +1,25 @@
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
# Test binary, built with `go test -c`
*.test
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
# Dependency directories (remove the comment below to include it)
# vendor/
# Go workspace file
go.work
go.work.sum
# env file
.env

View File

@ -1,3 +1,107 @@
## 0.13.0 (2024-10-25)
### Feat
- :sparkles: use time.Time.Before() instead of Sub()
## 0.12.0 (2024-10-25)
### Feat
- :sparkles: use tagger.when to find latest tag
## 0.11.1 (2024-07-11)
### Fix
- :bug: append newline after success message, use logger [CI SKIP]
## 0.11.0 (2024-07-11)
### Feat
- :sparkles: use log.textformatter
## 0.10.1 (2024-07-11)
### Fix
- revert: :rewind: fix: 🐛 use latest instead of last (oldest) tag - Add logs
## 0.10.0 (2024-07-11)
### Feat
- :loud_sound: add logs
## 0.9.0 (2024-07-11)
### Feat
- :sparkles: add support for adaptive cards
## 0.8.1 (2024-07-11)
### Fix
- :bug: use latest instead of last (oldest) tag
## 0.8.0 (2024-07-03)
### Feat
- :sparkles: add git username and password options for http
## 0.7.0 (2024-07-03)
### Feat
- :sparkles: output release url on success
## 0.6.0 (2024-06-27)
### Feat
- :sparkles: add error handling to fetching git tags if none found
## 0.5.1 (2024-06-27)
### Fix
- :bug: bump version to 0.5.1
## 0.5.0 (2024-06-27)
### Feat
- :sparkles: use go-git instead of native Git client to fetch latest tag
## 0.4.0 (2024-06-26)
### Feat
- :sparkles: add option to fetch git tags when getting latest
## 0.3.2 (2024-06-25)
### Fix
- :green_heart: set use_latest_git_tag to true
## 0.3.1 (2024-06-25)
### Fix
- :bug: add git to Dockerfile
## 0.3.0 (2024-06-25)
### Feat
- :sparkles: add skip_if_no_notes_file setting
## 0.2.3 (2024-06-25)
## 0.2.1 (2024-06-25)
### Fix

25
card.json Normal file
View File

@ -0,0 +1,25 @@
{
"type": "AdaptiveCard",
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.5",
"body": [
{
"type": "TextBlock",
"text": "${title}",
"wrap": true,
"style": "heading"
},
{
"type": "TextBlock",
"text": "Tag: ${tag}",
"wrap": true
}
],
"actions": [
{
"type": "Action.OpenUrl",
"title": "View release",
"url": "${url}"
}
]
}

25
cards/release.json Normal file
View File

@ -0,0 +1,25 @@
{
"type": "AdaptiveCard",
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.6",
"body": [
{
"type": "TextBlock",
"text": "Publish Adaptive Card Schema",
"wrap": true,
"style": "heading"
},
{
"type": "TextBlock",
"text": "Tag: 1.0.0",
"wrap": true
}
],
"actions": [
{
"type": "Action.OpenUrl",
"title": "View release",
"url": "https://google.com"
}
]
}

View File

@ -5,5 +5,5 @@ commitizen:
name: cz_conventional_commits
tag_format: $version
update_changelog_on_bump: true
version: 0.2.1
version: 0.13.0
version_scheme: semver

20
go.mod
View File

@ -10,9 +10,29 @@ require (
)
require (
dario.cat/mergo v1.0.0 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/ProtonMail/go-crypto v1.0.0 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/davidmz/go-pageant v1.0.2 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/go-fed/httpsig v1.1.0 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.5.0 // indirect
github.com/go-git/go-git/v5 v5.12.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
github.com/skeema/knownhosts v1.2.2 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/tools v0.13.0 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
)

93
go.sum
View File

@ -1,44 +1,137 @@
code.gitea.io/sdk/gitea v0.18.0 h1:+zZrwVmujIrgobt6wVBWCqITz6bn1aBjnCUHmpZrerI=
code.gitea.io/sdk/gitea v0.18.0/go.mod h1:IG9xZJoltDNeDSW0qiF2Vqx5orMWa7OhVWrjvrd5NpI=
dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY=
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
github.com/ProtonMail/go-crypto v1.0.0 h1:LRuvITjQWX+WIfr930YHG2HNfjR1uOfyf5vE0kC2U78=
github.com/ProtonMail/go-crypto v1.0.0/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0=
github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA=
github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU=
github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA=
github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg=
github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davidmz/go-pageant v1.0.2 h1:bPblRCh5jGU+Uptpz6LgMZGD5hJoOt7otgT454WvHn0=
github.com/davidmz/go-pageant v1.0.2/go.mod h1:P2EDDnMqIwG5Rrp05dTRITj9z2zpGcD9efWSkTNKLIE=
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
github.com/go-fed/httpsig v1.1.0 h1:9M+hb0jkEICD8/cAiNqEB66R87tTINszBRTjwjQzWcI=
github.com/go-fed/httpsig v1.1.0/go.mod h1:RCMrTZvN1bJYtofsG4rd5NaO5obxQ5xBkdiS7xsT7bM=
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI=
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic=
github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU=
github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow=
github.com/go-git/go-git/v5 v5.12.0 h1:7Md+ndsjrzZxbddRDZjF14qK+NN56sy6wkqaVrjZtys=
github.com/go-git/go-git/v5 v5.12.0/go.mod h1:FTM9VKtnI2m65hNI/TenDDDnUf2Q9FHnXYjuz9i5OEY=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek=
github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8=
github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg=
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4=
github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/skeema/knownhosts v1.2.2 h1:Iug2P4fLmDw9f41PB6thxUkNUkJzB5i+1/exaj40L3A=
github.com/skeema/knownhosts v1.2.2/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc=
golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q=
golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ=
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

34
main.go
View File

@ -6,7 +6,7 @@ import (
"gitea.dikurium.ch/InnoPeak/drone-gitea-release/plugin"
"github.com/kelseyhightower/envconfig"
"github.com/sirupsen/logrus"
log "github.com/sirupsen/logrus"
flag "github.com/spf13/pflag"
)
@ -15,7 +15,7 @@ var args plugin.Args
func init() {
if err := envconfig.Process("", &args); err != nil {
logrus.Fatalln(err)
log.Fatalln(err)
}
var (
@ -24,6 +24,7 @@ func init() {
tagRegex *string = flag.String("tag-regex", "", "Regex pattern to look for tag in tag-file")
notes *string = flag.String("notes", "", "Notes to use in release")
notesFile *string = flag.String("notes-file", "", "File to use for release notes")
logLevel *string = flag.String("log-level", "", "Level for logging")
)
flag.Parse()
@ -47,34 +48,25 @@ func init() {
if notesFile != nil && *notesFile != "" {
args.NotesFile = *notesFile
}
if logLevel != nil && *logLevel != "" {
args.Level = *logLevel
}
}
func main() {
logrus.SetFormatter(new(formatter))
log.SetFormatter(&log.TextFormatter{
DisableTimestamp: true,
})
switch args.Level {
case "debug":
logrus.SetFormatter(textFormatter)
logrus.SetLevel(logrus.DebugLevel)
log.SetLevel(log.DebugLevel)
case "trace":
logrus.SetFormatter(textFormatter)
logrus.SetLevel(logrus.TraceLevel)
log.SetLevel(log.TraceLevel)
}
if err := plugin.Exec(context.Background(), args); err != nil {
logrus.Fatalln(err)
log.Fatalln(err)
}
}
// default formatter that writes logs without including timestamp
// or level information.
type formatter struct{}
func (*formatter) Format(entry *logrus.Entry) ([]byte, error) {
return []byte(entry.Message), nil
}
// text formatter that writes logs with level information
var textFormatter = &logrus.TextFormatter{
DisableTimestamp: true,
}

View File

@ -9,6 +9,7 @@ import (
"text/template"
"code.gitea.io/sdk/gitea"
log "github.com/sirupsen/logrus"
)
var (
@ -23,18 +24,28 @@ type Args struct {
// Level defines the plugin log level.
Level string `envconfig:"PLUGIN_LOG_LEVEL"`
GiteaUrl string `envconfig:"PLUGIN_GITEA_URL"`
GiteaUsername string `envconfig:"PLUGIN_GITEA_USERNAME"`
GiteaPassword string `envconfig:"PLUGIN_GITEA_PASSWORD"`
Owner string `envconfig:"PLUGIN_OWNER"`
Repo string `envconfig:"PLUGIN_REPO"`
TitleFormat string `envconfig:"PLUGIN_TITLE_FORMAT"`
UseLatestGitTag bool `envconfig:"PLUGIN_USE_LATEST_GIT_TAG" default:"true"`
TagFile string `envconfig:"PLUGIN_TAG_FILE"`
TagRegex string `envconfig:"PLUGIN_TAG_REGEX"`
NotesFile string `envconfig:"PLUGIN_NOTES_FILE"`
Notes string `envconfig:"PLUGIN_NOTES"`
IsPrerelease bool `envconfig:"PLUGIN_IS_PRERELEASE"`
GiteaUrl string `envconfig:"PLUGIN_GITEA_URL"`
GiteaUsername string `envconfig:"PLUGIN_GITEA_USERNAME"`
GiteaPassword string `envconfig:"PLUGIN_GITEA_PASSWORD"`
GitUsername string `envconfig:"PLUGIN_GIT_USERNAME"`
GitPassword string `envconfig:"PLUGIN_GIT_PASSWORD"`
Owner string `envconfig:"PLUGIN_OWNER"`
Repo string `envconfig:"PLUGIN_REPO"`
TitleFormat string `envconfig:"PLUGIN_TITLE_FORMAT"`
UseLatestGitTag bool `envconfig:"PLUGIN_USE_LATEST_GIT_TAG" default:"true"`
TagFile string `envconfig:"PLUGIN_TAG_FILE"`
TagRegex string `envconfig:"PLUGIN_TAG_REGEX"`
NotesFile string `envconfig:"PLUGIN_NOTES_FILE"`
Notes string `envconfig:"PLUGIN_NOTES"`
IsPrerelease bool `envconfig:"PLUGIN_IS_PRERELEASE"`
SkipIfNoNotesFile bool `envconfig:"PLUGIN_SKIP_IF_NO_NOTES_FILE"`
FetchGitTags bool `envconfig:"PLUGIN_FETCH_GIT_TAGS" default:"true"`
}
type ReleaseCard struct {
Title string
Tag string
Url string
}
type TitleTemplateCtx struct {
@ -60,6 +71,10 @@ func Exec(ctx context.Context, args Args) error {
content, err := os.ReadFile(args.NotesFile)
if err != nil {
if os.IsNotExist(err) && args.SkipIfNoNotesFile {
log.Info("No notes file found, skipping release")
return nil
}
return fmt.Errorf("error reading notes file %w", err)
}
@ -69,12 +84,23 @@ func Exec(ctx context.Context, args Args) error {
}
if args.UseLatestGitTag {
tag, err = getLatestGitTag()
var options = make([]GetLatestGitTagOption, 0)
if args.GitUsername != "" && args.GitPassword != "" {
options = append(options, SetBasicAuth(args.GitUsername, args.GitPassword))
}
if args.FetchGitTags {
options = append(options, FetchTags())
}
tag, err = getLatestGitTag(options...)
if err != nil {
return fmt.Errorf("error getting git tag %w", err)
}
log.WithField("tag", tag).Info("Fetched latest git tag")
} else if args.TagFile != "" {
log.WithField("file", args.TagFile).Info("Reading tag from file")
var pattern = defaultTagRegex
if args.TagRegex != "" {
pattern = regexp.MustCompile(args.TagRegex)
@ -97,6 +123,8 @@ func Exec(ctx context.Context, args Args) error {
tag = matches[i]
}
}
log.WithField("tag", tag).Info("Found tag")
} else {
return fmt.Errorf("latest git tag or tag file must be given")
}
@ -121,13 +149,18 @@ func Exec(ctx context.Context, args Args) error {
title = titleBuffer.String()
log.WithFields(log.Fields{
"template": titleTmpl.DefinedTemplates(),
"title": title,
}).Info("Generated title with template")
client, err := gitea.NewClient(args.GiteaUrl, gitea.SetBasicAuth(args.GiteaUsername, args.GiteaPassword))
if err != nil {
return fmt.Errorf("error creating Gitea client %w", err)
}
_, _, err = client.CreateRelease(args.Owner, args.Repo, gitea.CreateReleaseOption{
release, _, err := client.CreateRelease(args.Owner, args.Repo, gitea.CreateReleaseOption{
TagName: tag,
Title: title,
Note: note,
@ -138,5 +171,18 @@ func Exec(ctx context.Context, args Args) error {
return fmt.Errorf("error creating Gitea release %w", err)
}
releaseURL := fmt.Sprintf("%s/%s/%s/releases/tag/%s", args.GiteaUrl, args.Owner, args.Repo, release.TagName)
log.WithField("url", releaseURL).Info("Successfully created release")
writeCard(
args.Pipeline.Card.Path,
"https://gitea.dikurium.ch/InnoPeak/drone-gitea-release/raw/branch/main/card.json",
ReleaseCard{
Title: title,
Tag: tag,
Url: releaseURL,
},
)
return err
}

View File

@ -9,18 +9,109 @@ import (
"encoding/json"
"fmt"
"io"
"net/http"
"os"
"os/exec"
"time"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing/transport/client"
githttp "github.com/go-git/go-git/v5/plumbing/transport/http"
log "github.com/sirupsen/logrus"
)
func getLatestGitTag() (string, error) {
tag, err := exec.Command("git", "describe", "--tags", "--abbrev=0").Output()
type GetLatestGitTagOption func(repo *git.Repository) error
type BasicAuthTransport struct {
Username string
Password string
RoundTriper http.RoundTripper
}
func (bat BasicAuthTransport) RoundTrip(req *http.Request) (resp *http.Response, err error) {
creds := base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s:%s", bat.Username, bat.Password)))
req.Header.Set("Authorization", fmt.Sprintf("Basic %s", creds))
return bat.RoundTriper.RoundTrip(req)
}
func SetBasicAuth(username, password string) func(repo *git.Repository) error {
return func(repo *git.Repository) error {
log.Println("Configuring basic auth for https")
customClient := &http.Client{
Transport: BasicAuthTransport{username, password, http.DefaultTransport},
}
// Override http(s) default protocol to use our custom client
client.InstallProtocol("https", githttp.NewClient(customClient))
return nil
}
}
func FetchTags() func(repo *git.Repository) error {
return func(repo *git.Repository) error {
log.Info("Fetching git tags")
err := repo.Fetch(&git.FetchOptions{Tags: git.AllTags})
if err == git.NoErrAlreadyUpToDate {
return nil
}
return err
}
}
func getLatestGitTag(options ...GetLatestGitTagOption) (string, error) {
var (
tag string
tagDate *time.Time
err error
)
repo, err := git.PlainOpen(".")
if err != nil {
return "", fmt.Errorf("error getting git tag %w", err)
return "", fmt.Errorf("error opening git repo at %s: %w", ".", err)
}
return string(tag), err
for _, opt := range options {
err := opt(repo)
if err != nil {
return "", err
}
}
tags, err := repo.TagObjects()
if err != nil {
return "", fmt.Errorf("error getting git tags %w", err)
}
for {
t, err := tags.Next()
if err == io.EOF {
break
}
if err != nil {
return "", fmt.Errorf("error iterating tags %w", err)
}
if tagDate != nil && t.Tagger.When.Before(*tagDate) {
continue
}
tagDate = &t.Tagger.When
tag = t.Name
}
if tag == "" {
return tag, fmt.Errorf("couldn't find any git tags")
}
return tag, err
}
func writeCard(path, schema string, card interface{}) {