woodpecker icon indicating copy to clipboard operation
woodpecker copied to clipboard

Add support for release event (Github, Gitea, Gitlab)

Open LamaAni opened this issue 3 years ago • 19 comments

As a github developer (both public and Enterprise) I would like to be able to catch and run CI on the release event, allowing to add artifacts for release via the github GUI.

Reasons:

  1. It is easy for all users (management/lower level devs) to release, revert, get artifacts etc from release page.
  2. It is a part of the github UI.

Changes:

  1. Added global webhook "release"
  2. Added support for parsing webhook "release" to the github vendor.
    • No release commit. We are using the /refs/tags/... Ref.
    • No branch is associated.

LamaAni avatar Feb 08 '22 17:02 LamaAni

this is a new feature and because of feature freeze will be assigned to v1.0.0 :)

6543 avatar Feb 08 '22 17:02 6543

PS: https://woodpecker-ci.org/docs/administration/vcs/overview#supported-features should be extended

6543 avatar Feb 08 '22 17:02 6543

Is there a difference between release and tag in Github / Gitea etc? Is it possible to create multiple releases for a single tag?

anbraten avatar Feb 08 '22 17:02 anbraten

Codecov Report

Merging #764 (05a4463) into master (e79ad00) will increase coverage by 0.66%. The diff coverage is 84.61%.

@@            Coverage Diff             @@
##           master     #764      +/-   ##
==========================================
+ Coverage   51.58%   52.24%   +0.66%     
==========================================
  Files          79       79              
  Lines        6074     6203     +129     
==========================================
+ Hits         3133     3241     +108     
- Misses       2760     2776      +16     
- Partials      181      186       +5     
Impacted Files Coverage Δ
server/remote/gitea/parse.go 32.35% <72.22%> (+13.48%) :arrow_up:
server/remote/gitea/helper.go 86.27% <81.25%> (-1.71%) :arrow_down:
server/remote/github/parse.go 85.71% <83.01%> (-1.69%) :arrow_down:
server/remote/github/github.go 16.34% <87.50%> (+0.23%) :arrow_up:
server/remote/gitlab/convert.go 72.22% <90.62%> (+3.20%) :arrow_up:
server/model/const.go 66.66% <100.00%> (ø)
server/remote/gitlab/gitlab.go 29.06% <100.00%> (+1.97%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update e79ad00...05a4463. Read the comment docs.

codecov-commenter avatar Feb 08 '22 17:02 codecov-commenter

Is there a difference between release and tag in Github / Gitea etc? Is it possible to create multiple releases for a single tag?

The main difference is the procedure, message and title. I would like to allow my users to do tagging, whilst not allowing the release. Further, release can have artifacts.

eg. Release -> tag, but not tag -> release

LamaAni avatar Feb 08 '22 17:02 LamaAni

this is a new feature and because of feature freeze will be assigned to v1.0.0 :)

Hi, that is OK. that version is getting bigger ;) I'm using my own build for now since Bloomberg requires some custom networking. I am though making the users do some loops around the when: thing... so I am waiting for 1.0.0.

LamaAni avatar Feb 08 '22 17:02 LamaAni

@LamaAni Could you try to add the release event for Gitlab and Gitea as well, so we have it for our 3 most used SCMs? If you need help doing that just ask, please.

anbraten avatar Feb 08 '22 18:02 anbraten

@LamaAni Could you try to add the release event for Gitlab and Gitea as well, so we have it for our 3 most used SCMs? If you need help doing that just ask, please.

Hi, I could try and add that. But I cant test that at the moment and before I do I would need a sample json. Can you post one? @anbraten

LamaAni avatar Feb 08 '22 19:02 LamaAni

PS: https://woodpecker-ci.org/docs/administration/vcs/overview#supported-features should be extended

Fixed

LamaAni avatar Feb 08 '22 20:02 LamaAni

@anbraten Do you have that JSON? Or we can do that in another PR...

LamaAni avatar Feb 09 '22 19:02 LamaAni

Gitlab

Content-Type: application/json
User-Agent: GitLab/14.8.0-pre
X-Gitlab-Event: Release Hook
X-Gitlab-Event-UUID: 579ec8e1-b801-4a48-8ed8-xxx
{
  "id": 4268085,
  "created_at": "2022-02-09 20:19:09 UTC",
  "description": "new version desc",
  "name": "Awesome version 0.0.2",
  "released_at": "2022-02-09 20:19:09 UTC",
  "tag": "0.0.2",
  "object_kind": "release",
  "project": {
    "id": 32521798,
    "name": "ci",
    "description": "",
    "web_url": "https://gitlab.com/anbratens-test/ci",
    "avatar_url": null,
    "git_ssh_url": "[email protected]:anbratens-test/ci.git",
    "git_http_url": "https://gitlab.com/anbratens-test/ci.git",
    "namespace": "anbratens-test",
    "visibility_level": 0,
    "path_with_namespace": "anbratens-test/ci",
    "default_branch": "main",
    "ci_config_path": "",
    "homepage": "https://gitlab.com/anbratens-test/ci",
    "url": "[email protected]:anbratens-test/ci.git",
    "ssh_url": "[email protected]:anbratens-test/ci.git",
    "http_url": "https://gitlab.com/anbratens-test/ci.git"
  },
  "url": "https://gitlab.com/anbratens-test/ci/-/releases/0.0.2",
  "action": "create",
  "assets": {
    "count": 4,
    "links": [

    ],
    "sources": [
      {
        "format": "zip",
        "url": "https://gitlab.com/anbratens-test/ci/-/archive/0.0.2/ci-0.0.2.zip"
      },
      {
        "format": "tar.gz",
        "url": "https://gitlab.com/anbratens-test/ci/-/archive/0.0.2/ci-0.0.2.tar.gz"
      },
      {
        "format": "tar.bz2",
        "url": "https://gitlab.com/anbratens-test/ci/-/archive/0.0.2/ci-0.0.2.tar.bz2"
      },
      {
        "format": "tar",
        "url": "https://gitlab.com/anbratens-test/ci/-/archive/0.0.2/ci-0.0.2.tar"
      }
    ]
  },
  "commit": {
    "id": "0b8c02955ba445ea70d22824d9589678852e2b93",
    "message": "Initial commit",
    "title": "Initial commit",
    "timestamp": "2022-01-03T10:39:51+00:00",
    "url": "https://gitlab.com/anbratens-test/ci/-/commit/0b8c02955ba445ea70d22824d9589678852e2b93",
    "author": {
      "name": "Anbraten",
      "email": "[email protected]"
    }
  }
}

Gitea

Request URL: http://xxx
Request method: POST
Content-Type: application/json
X-GitHub-Delivery: c00b8c17-f187-4d5a-bd17-xxx
X-GitHub-Event: release
X-Gitea-Delivery: c00b8c17-f187-4d5a-bd17-xxx
X-Gitea-Event: release
X-Gitea-Signature: xxx
X-Gogs-Delivery: c00b8c17-f187-4d5a-bd17-xxx
X-Gogs-Event: release
X-Gogs-Signature: xxx
X-Hub-Signature: sha1=e4d4286d15c3f9870fe2c239067eae12xxxx
X-Hub-Signature-256: sha256=74515aa84467fdb69b68133d67a17a07096b5e745f3xxxxx
{
  "action": "published",
  "release": {
    "id": 48,
    "tag_name": "0.0.5",
    "target_commitish": "main",
    "name": "Version 0.0.5",
    "body": "",
    "url": "https://git.xxx/api/v1/repos/anbraten/demo/releases/48",
    "html_url": "https://git.xxx/anbraten/demo/releases/tag/0.0.5",
    "tarball_url": "https://git.xxx/anbraten/demo/archive/0.0.5.tar.gz",
    "zipball_url": "https://git.xxx/anbraten/demo/archive/0.0.5.zip",
    "draft": false,
    "prerelease": false,
    "created_at": "2022-02-09T20:23:05Z",
    "published_at": "2022-02-09T20:23:05Z",
    "author": {"id":1,"login":"anbraten","full_name":"Anton Bracke","email":"[email protected]","avatar_url":"https://git.xxx/user/avatar/anbraten/-1","language":"","is_admin":false,"last_login":"0001-01-01T00:00:00Z","created":"2018-03-21T10:04:48Z","restricted":false,"active":false,"prohibit_login":false,"location":"world","website":"https://xxx","description":"","visibility":"public","followers_count":1,"following_count":1,"starred_repos_count":1,"username":"anbraten"},
    "assets": []
  },
  "repository": {
    "id": 77,
    "owner": {"id":1,"login":"anbraten","full_name":"Anton Bracke","email":"[email protected]","avatar_url":"https://git.xxx/user/avatar/anbraten/-1","language":"","is_admin":false,"last_login":"0001-01-01T00:00:00Z","created":"2018-03-21T10:04:48Z","restricted":false,"active":false,"prohibit_login":false,"location":"world","website":"https://xxx","description":"","visibility":"public","followers_count":1,"following_count":1,"starred_repos_count":1,"username":"anbraten"},
    "name": "demo",
    "full_name": "anbraten/demo",
    "description": "",
    "empty": false,
    "private": true,
    "fork": false,
    "template": false,
    "parent": null,
    "mirror": false,
    "size": 59,
    "html_url": "https://git.xxx/anbraten/demo",
    "ssh_url": "ssh://[email protected]:22/anbraten/demo.git",
    "clone_url": "https://git.xxx/anbraten/demo.git",
    "original_url": "",
    "website": "",
    "stars_count": 0,
    "forks_count": 1,
    "watchers_count": 1,
    "open_issues_count": 2,
    "open_pr_counter": 2,
    "release_counter": 4,
    "default_branch": "main",
    "archived": false,
    "created_at": "2021-08-30T20:54:13Z",
    "updated_at": "2022-01-09T01:29:23Z",
    "permissions": {
      "admin": true,
      "push": true,
      "pull": true
    },
    "has_issues": true,
    "internal_tracker": {
      "enable_time_tracker": true,
      "allow_only_contributors_to_track_time": true,
      "enable_issue_dependencies": true
    },
    "has_wiki": false,
    "has_pull_requests": true,
    "has_projects": true,
    "ignore_whitespace_conflicts": false,
    "allow_merge_commits": true,
    "allow_rebase": true,
    "allow_rebase_explicit": true,
    "allow_squash_merge": true,
    "default_merge_style": "squash",
    "avatar_url": "",
    "internal": false,
    "mirror_interval": ""
  },
  "sender": {"id":1,"login":"anbraten","full_name":"Anbraten","email":"[email protected]","avatar_url":"https://git.xxx/user/avatar/anbraten/-1","language":"","is_admin":false,"last_login":"0001-01-01T00:00:00Z","created":"2018-03-21T10:04:48Z","restricted":false,"active":false,"prohibit_login":false,"location":"World","website":"https://xxx","description":"","visibility":"public","followers_count":1,"following_count":1,"starred_repos_count":1,"username":"anbraten"}
}

anbraten avatar Feb 09 '22 20:02 anbraten

@anbraten I'll update the PR when I get a chance. I'm having network issues with docker service in services. Something about the dns resolve.

LamaAni avatar Feb 11 '22 18:02 LamaAni

Added support for gita and gitlab. @anbraten @6543 These are not tested since I dont have the means.

LamaAni avatar Mar 02 '22 00:03 LamaAni

linter fail :D

6543 avatar Mar 02 '22 17:03 6543

linter fail :D

On?

LamaAni avatar Mar 02 '22 18:03 LamaAni

Deployment of preview was successful: https://woodpecker-ci-woodpecker-pr-764.surge.sh

woodpecker-bot avatar May 17 '22 12:05 woodpecker-bot

Hi, Sorry for the late responses. I have set time aside to fix my PR's in about a couple of weeks. I'll fix these then, @6543

LamaAni avatar May 18 '22 13:05 LamaAni

dont worry we also dont rush - proper solutions are better than things merged in a hurry

6543 avatar May 18 '22 14:05 6543

We should apply https://github.com/woodpecker-ci/woodpecker/pull/917 here too if there's no branch associated, but actually releases can have branches that should be parsed here.

qwerty287 avatar Aug 03 '22 14:08 qwerty287

-> https://github.com/woodpecker-ci/woodpecker/pull/3226

qwerty287 avatar Jan 20 '24 10:01 qwerty287