diff --git a/.changelog.yml b/.changelog.yml new file mode 100644 index 0000000..c1ab6d4 --- /dev/null +++ b/.changelog.yml @@ -0,0 +1,38 @@ +# The full repository name +repo: plugins/gitea-package + +# Service type (gitea or github) +service: gitea + +# Base URL for Gitea instance if using gitea service type (optional) +# Default: https://gitea.com +base-url: https://gitea.ocram85.com + +# Changelog groups and which labeled PRs to add to each group +groups: + - name: 🐛 BUGFIXES + labels: + - bug + - name: ✨ FEATURES + labels: + - feature + - name: 🛠️ ENHANCEMENTS + labels: + - enhancement + - name: 📦 BUILD + labels: + - pipeline + - name: 🤖 DEPENDENCIES + labels: + - renovate + - name: 📚 DOCS + labels: + - docs + - name: ⚙️ META + labels: + - meta + - name: 🔖 MISC + default: true + +# regex indicating which labels to skip for the changelog +skip-labels: skip-changelog|backport\/.+ diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..b72665a --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,37 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Update GiteaChangelog", + "type": "shell", + "command": [ + "mv 'CHANGELOG.md' 'CHANGELOG.back' &&", + "changelog -m '${input:Milestone}' --token '${input:GiteaToken}' -c .changelog.yml generate > CHANGELOG.md &&", + "echo '' >> CHANGELOG.md &&", + "cat CHANGELOG.back >> CHANGELOG.md &&", + "rm CHANGELOG.back" + ], + "problemMatcher": [] + } + ], + "inputs": [ + { + "id": "GiteaToken", + "type": "command", + "command": "shellCommand.execute", + "args": { + "command": "echo $GITEA_TOKEN", + "description": "Your personal Gitea access token" + } + }, + { + "id": "Milestone", + "type": "command", + "command": "shellCommand.execute", + "args": { + "description": "Select or enter a open milestone", + "command": "tea milestone ls -f title --output simple" + } + } + ] +} diff --git a/.woodpecker/ci.yml b/.woodpecker/ci.yml new file mode 100644 index 0000000..2e01d7c --- /dev/null +++ b/.woodpecker/ci.yml @@ -0,0 +1,82 @@ +when: + - event: [pull_request, tag, cron] + - event: push + branch: + - ${CI_REPO_DEFAULT_BRANCH} + +variables: + - &build_plugin 'woodpeckerci/plugin-docker-buildx:3.2.1' + # deployment targets + - &publish_repos 'ocram85/plugin-gitea-package,gitea.ocram85.com/plugins/gitea-package' + # logins for deployment targets + - publish_logins: &publish_logins + # Default DockerHub login + - registry: https://index.docker.io/v1/ + username: + from_secret: docker_user + password: + from_secret: docker_passwd + # Additional Quay.IO login + - registry: https://gitea.ocram85.com + username: + from_secret: gitea_user + password: + from_secret: gitea_passwd + +steps: + test: + image: *build_plugin + settings: + dry_run: true + registry: gitea.ocram85.com + repo: test + dockerfile: Dockerfile + platforms: linux/amd64 + auto_tag: true + build_args: + - VERSION=${CI_COMMIT_TAG:-PR ${CI_COMMIT_PULL_REQUEST}} + - TAG=${CI_COMMIT_TAG} + when: + event: pull_request + branch: ${CI_REPO_DEFAULT_BRANCH} + + publish: + image: *build_plugin + settings: + repo: *publish_repos + dockerfile: Dockerfile + platforms: linux/amd64 + auto_tag: true + logins: *publish_logins + build_args: + - VERSION=${CI_COMMIT_TAG:-PR ${CI_COMMIT_PULL_REQUEST}} + - TAG=${CI_COMMIT_TAG} + when: + event: [push, tag, cron] + branch: ${CI_REPO_DEFAULT_BRANCH} + + build-next: + image: *build_plugin + settings: + repo: *publish_repos + dockerfile: Dockerfile + platforms: linux/amd64 + tag: next + logins: *publish_logins + build_args: + - VERSION=${CI_COMMIT_TAG:-PR ${CI_COMMIT_PULL_REQUEST}} + - TAG=${CI_COMMIT_TAG} + when: + event: [pull_request] + + gitea-release: + image: plugins/gitea-release + settings: + api_key: + from_secret: RENOVATE_TOKEN + base_url: https://gitea.ocram85.com + title: ${CI_COMMIT_TAG} + note: "> :bulb: **Note:** See [CHANGELOG.md](src/branch/master/CHANGELOG.md) for recent changes." + when: + event: [tag] + branch: ${CI_REPO_DEFAULT_BRANCH} diff --git a/.woodpecker/test-image.yml b/.woodpecker/test-image.yml new file mode 100644 index 0000000..87c8843 --- /dev/null +++ b/.woodpecker/test-image.yml @@ -0,0 +1,23 @@ +when: + - event: [pull_request, tag, cron] + - event: push + branch: + - ${CI_REPO_DEFAULT_BRANCH} + +depends_on: + - "ci" + +steps: + test-next: + image: gitea.ocram85.com/plugins/gitea-package:next + pull: true + settings: + debug: "true" + owner: "testuser" + package_name: "dummy_package" + package_version: "0.1.0" + file_name: "./README.md" + update: "true" + when: + event: pull_request + branch: ${CI_REPO_DEFAULT_BRANCH} diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..e69de29 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a48be7f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM curlimages/curl:8.7.1 +LABEL org.opencontainers.image.authors="marco@ocram85.com" +#ENV PLUGIN_OWNER +#ENV PLUGIN_PACKAGE_NAME +#ENV PLUGIN_PACKAGE_VERSION +#ENV PLUGIN_FILE_NAME + +#ENV PLUGIN_UPDATE +#ENV PLUGIN_DEBUG="1" +USER root +COPY --chown=100:101 --chmod=755 ./gitea-package.sh /app/gitea-package.sh +#RUN [ "chmod", "+x", "/app/gitea-package.sh" ] + +USER curl_user + +ENTRYPOINT [ "/app/gitea-package.sh" ] diff --git a/README.md b/README.md index c767df2..1630e8a 100644 --- a/README.md +++ b/README.md @@ -17,12 +17,12 @@
- Pluging to Publish Artifatcs to Gitea Generic Package Registry + Plugin to Publish Artifacts to Gitea Generic Package Registry
diff --git a/gitea-package.sh b/gitea-package.sh new file mode 100755 index 0000000..7d37b5a --- /dev/null +++ b/gitea-package.sh @@ -0,0 +1,65 @@ +#!/usr/bin/env sh + +set -e + +say() { + if [ -n "$2" ]; then + printf "🤖 \e[32mgitea-package\e[0m \e[36m[⚒️ %s]\e[0m: %s \n" "$2" "$1" + else + printf "🤖 \e[32mgitea-package\e[0m: %s \n" "$1" + fi +} + +sayE() { + if [ -n "$2" ]; then + printf "🤖 \e[31mgitea-package\e[0m \e[36m[⚒️ %s]\e[0m: %s \n" "$2" "$1" 1>&2 + else + printf "🤖 \e[31mgitea-package\e[0m: %s \n" "$1" 1>&2 + fi +} + +sayW() { + if [ -n "$2" ]; then + printf "🤖 \e[33mgitea-package\e[0m \e[36m[⚒️ %s]\e[0m: %s \n" "$2" "$1" 1>&2 + else + printf "🤖 \e[33mgitea-package\e[0m: %s \n" "$1" 1>&2 + fi +} + +showHelp() { + cat << HELP + 🤖 gitea-package Woodpecker-CI Plugin + + Syntax: +HELP +} + +showENV() { + env | sort +} + +showSettings() { + say "PLUGIN_OWNER: $PLUGIN_OWNER" "showSettings" + say "PLUGIN_PACKAGE_NAME: $PLUGIN_PACKAGE_NAME" "showSettings" + say "PLUGIN_PACKAGE_VERSION: $PLUGIN_PACKAGE_VERSION" "showSettings" + say "PLUGIN_FILE_NAME: $PLUGIN_FILE_NAME" "showSettings" + say "PLUGIN_UPDATE: $PLUGIN_UPDATE" "showSettings" +} + +uploadArtifact() { + curl --user your_username:your_password_or_token \ + --upload-file path/to/file.bin \ + https://gitea.example.com/api/packages/testuser/generic/test_package/1.0.0/file.bin +} + +main() { + if [ -n "$PLUGIN_DEBUG" ]; then + sayW "Debug mode enabled." + showSettings + sayW "Available ENV vars:" + showENV + exit 0 + fi +} + +main "$@"