Allow to use this repository as Forgejo Action
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Benjamin Renard 2024-03-10 17:07:47 +01:00
parent 0b15f1c2a8
commit a5a91d14cf
3 changed files with 114 additions and 6 deletions

View file

@ -1,6 +1,6 @@
FROM alpine FROM node:16-alpine
ADD aptly-publish /bin/ ADD aptly-publish /bin/
RUN chmod +x /bin/aptly-publish RUN chmod +x /bin/aptly-publish
RUN apk -Uuv add python3 py3-requests py3-urllib3 py3-pip RUN apk -Uuv add python3 py3-requests py3-urllib3 py3-pip bash
RUN pip install debian-parser RUN pip install debian-parser
ENTRYPOINT /bin/aptly-publish ENTRYPOINT /bin/aptly-publish

View file

@ -1,6 +1,6 @@
# CI plugin to publish Debian package on a Aptly repository # CI plugin to publish Debian package on a Aptly repository
This docker image could be used as an Woodpecker CI plugin to publish one (or more) Debian package on a Aptly repository using its API. It also could be used with Gitlab CI to define a publishing job. This docker image could be used as an Woodpecker CI plugin to publish one (or more) Debian package on a Aptly repository using its API. It also could be used with Gitlab CI and Forgejo Actions to define a publishing job.
This plugin will try to : This plugin will try to :
@ -28,7 +28,7 @@ In case of error, it will exit with a detailed error message (within the limits
The below pipeline configuration demonstrates simple usage as Woodpecker CI plugin: The below pipeline configuration demonstrates simple usage as Woodpecker CI plugin:
``` ```yaml
pipeline: pipeline:
publish: publish:
image: brenard/aptly-publish image: brenard/aptly-publish
@ -63,7 +63,7 @@ pipeline:
The following pipeline configuration demonstrates a simple usage to build and publish a debian package: The following pipeline configuration demonstrates a simple usage to build and publish a debian package:
``` ```yaml
stages: stages:
- build - build
- publish - publish
@ -98,9 +98,62 @@ publish:
- echo "Publish Bullseye debian packages on APT repository..." - echo "Publish Bullseye debian packages on APT repository..."
- aptly-publish - aptly-publish
needs: needs:
- 'build' - "build"
rules: rules:
- if: $CI_COMMIT_TAG - if: $CI_COMMIT_TAG
``` ```
The parameters are passed using environment variables as designed with a Woodpecker CI plugin. Consequently, you could refer to the previous section for details about these parameters. For the password to request Aptly API, you have to set the `APTLY_API_PASSWORD` CI variable in your Gitlab project configuration (be sure to check _Masked variable_). The parameters are passed using environment variables as designed with a Woodpecker CI plugin. Consequently, you could refer to the previous section for details about these parameters. For the password to request Aptly API, you have to set the `APTLY_API_PASSWORD` CI variable in your Gitlab project configuration (be sure to check _Masked variable_).
## With Forgejo Actions
The following workflow configuration demonstrates a simple usage to build and publish a debian package:
```yaml
---
name: Build and publish forgejo-runner Debian package
on: [create]
jobs:
build:
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Build Debian package
run: ./build.sh
- name: Upload Debian package files
uses: actions/upload-artifact@v3
with:
name: dist
path: |
dist/*.buildinfo
dist/*.changes
dist/*.deb
dist/*.dsc
dist/*.tar.gz
publish:
runs-on: docker
container:
image: docker.io/brenard/aptly-publish:latest
steps:
- name: "Download Debian package files"
uses: actions/download-artifact@v3
with:
name: dist
- name: "Publish Debian package on Aptly repository"
uses: https://gitea.zionetrix.net/bn8/aptly-publish@master
with:
api_url: https://your.aptly.tld/api
api_username: myproject
api_password: ${{ secrets.APTLY_API_PASSWORD }}
prefix: debian
repo_component: main
repo_name: debian_stable_main
path: "./"
source_name: myproject
max_retries: 2
force_overwrite: true
```
The parameters are passed using environment variables as designed with a Woodpecker CI plugin. Consequently, you could refer to the previous section for details about these parameters. For the password to request Aptly API, you have to set the `APTLY_API_PASSWORD` Actions secret in your Forgejo project configuration.

55
action.yml Normal file
View file

@ -0,0 +1,55 @@
---
name: "Publish Debian package on a Aptly repository"
author: "Benjamin Renard <brenard@zionetrix.net>"
description: "Publish one (or more) Debian package on a Aptly repository using its API"
inputs:
api_url:
description: "Your Aptly API URL"
required: true
api_username:
description: "Username to authenticate on your Aptly API"
required: true
api_password:
description: "Password to authenticate on your Aptly API"
required: true
prefix:
description: "The publishing prefix"
default: "."
repo_component:
description: "The component name to publish on"
default: "main"
repo_name:
description: "The repository name to publish on. If not specified, it will be computed using the specified prefix and component and the detected package distribution. See doc for details."
path:
description: "Path to the directory where files to publish are stored"
default: "dist"
source_name:
description: "Name of the source package to publish (optional, default: all changes files are will be publish)"
max_retries:
description: "The number of retry in case of error calling the Aptly API (optional, default: no retry)"
force_overwrite:
description: "When publishing, overwrite files in pool/ directory without notice"
default: false
runs:
using: "composite"
steps:
- name: Set GitHub Path
run: echo "$GITHUB_ACTION_PATH" >> $GITHUB_PATH
shell: bash
env:
GITHUB_ACTION_PATH: ${{ github.action_path }}
- name: "Publishing"
env:
APTLY_API_URL: ${{ inputs.api_url }}
APTLY_API_USERNAME: ${{ inputs.api_username }}
APTLY_API_PASSWORD: ${{ inputs.api_password }}
APTLY_PREFIX: ${{ inputs.prefix }}
APTLY_REPO_COMPONENT: ${{ inputs.repo_component }}
APTLY_REPO_NAME: ${{ inputs.repo_name }}
APTLY_PATH: ${{ inputs.path }}
APTLY_SOURCE_NAME: ${{ inputs.source_name }}
APTLY_MAX_RETRIES: ${{ inputs.max_retries }}
APTLY_FORCE_OVERWRITE: ${{ inputs.force_overwrite }}
run: aptly-publish