From 75d6935024d701e0bf61b62bf5e8febbb95abf05 Mon Sep 17 00:00:00 2001 From: Kevin Yue Date: Sat, 16 Oct 2021 21:23:42 +0800 Subject: [PATCH 1/9] add action --- Dockerfile | 8 ++++++++ action.yml | 25 ++++++++++++++++++++++++ build.sh | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++ entrypoint.sh | 10 ++++++++++ 4 files changed, 96 insertions(+) create mode 100644 Dockerfile create mode 100644 action.yml create mode 100755 build.sh create mode 100755 entrypoint.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f82e2a2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM opensuse/tumbleweed + +RUN zypper ref && zypper in -y -f osc + +COPY entrypoint.sh /entrypoint.sh +COPY build.sh /build.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..d373632 --- /dev/null +++ b/action.yml @@ -0,0 +1,25 @@ +name: 'publish-obs-package' +description: 'Publish an OBS package' +inputs: + api: + description: OBS API url + required: false + default: https://api.opensuse.org + project: + description: OBS project name + required: true + package: + description: Package name + required: true + username: + description: OBS username + required: true + password: + description: OBS password + required: true + files: + description: OBS files + required: true +runs: + using: docker + image: Dockerfile diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..3f9c782 --- /dev/null +++ b/build.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +set -o errexit -o pipefail -o nounset + +api=$INPUT_API +project=$INPUT_PROJECT +package=$INPUT_PACKAGE +username=$INPUT_USERNAME +password=$INPUT_PASSWORD +files=$INPUT_FILES + +assert_non_empty() { + name=$1 + value=$2 + if [[ -z "$value" ]]; then + echo "::error::Invalid Value: $name is empty." >&2 + exit 1 + fi +} + +assert_non_empty inputs.project "$project" +assert_non_empty inputs.package "$package" +assert_non_empty inputs.username "$username" +assert_non_empty inputs.password "$password" +assert_non_empty inputs.files "$files" + +export HOME=/home/builder + +echo "::group::Intializing .oscrc" +cat $HOME/.oscrc < Date: Sat, 16 Oct 2021 21:43:45 +0800 Subject: [PATCH 2/9] change docker image --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index f82e2a2..53a9a50 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM opensuse/tumbleweed +FROM opensuse/leap RUN zypper ref && zypper in -y -f osc From ae781df190ea32bd147688a82db7e75b56398b68 Mon Sep 17 00:00:00 2001 From: Kevin Yue Date: Sat, 16 Oct 2021 23:16:32 +0800 Subject: [PATCH 3/9] add cat --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 53a9a50..50be553 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM opensuse/leap -RUN zypper ref && zypper in -y -f osc +RUN zypper ref && zypper in -y osc cat COPY entrypoint.sh /entrypoint.sh COPY build.sh /build.sh From c9802a921d3e954c53da434909f7bdc60e3faa70 Mon Sep 17 00:00:00 2001 From: Kevin Yue Date: Sat, 16 Oct 2021 23:54:25 +0800 Subject: [PATCH 4/9] Update build.sh --- build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 3f9c782..34e8a59 100755 --- a/build.sh +++ b/build.sh @@ -27,7 +27,7 @@ assert_non_empty inputs.files "$files" export HOME=/home/builder echo "::group::Intializing .oscrc" -cat $HOME/.oscrc < $HOME/.oscrc < Date: Sat, 16 Oct 2021 23:55:05 +0800 Subject: [PATCH 5/9] Update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 50be553..c8d3cc6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM opensuse/leap -RUN zypper ref && zypper in -y osc cat +RUN zypper ref && zypper in -y osc COPY entrypoint.sh /entrypoint.sh COPY build.sh /build.sh From cf3ec0516981b582121ded0330930d7935bc3727 Mon Sep 17 00:00:00 2001 From: Kevin Yue Date: Sun, 17 Oct 2021 00:22:05 +0800 Subject: [PATCH 6/9] Update build.sh --- build.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 34e8a59..8ea6781 100755 --- a/build.sh +++ b/build.sh @@ -43,11 +43,12 @@ osc checkout $project $package echo "::endgroup::" echo "::group::Copying files into $project/$package" -cp -rt "$project/$package" $files +cd $GITHUB_WORKSPACE +cp -rt "$HOME/$project/$package" $files echo "::endgroup::" echo "::group::Publishing to OBS" -cd $project/$package +cd $HOME/$project/$package osc addremove osc commit -m "OBS release: git#${GITHUB_SHA}" echo "::endgroup::" From c857ab537eb5a96f56f5be4600e2b457bf07d774 Mon Sep 17 00:00:00 2001 From: Kevin Yue Date: Sun, 17 Oct 2021 09:46:07 +0800 Subject: [PATCH 7/9] add the commit_message input --- action.yml | 7 +++++-- build.sh | 10 ++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index d373632..af65026 100644 --- a/action.yml +++ b/action.yml @@ -9,7 +9,7 @@ inputs: description: OBS project name required: true package: - description: Package name + description: OBS package name required: true username: description: OBS username @@ -18,8 +18,11 @@ inputs: description: OBS password required: true files: - description: OBS files + description: OBS package files required: true + commit_message: + description: Commit message to use when submitting the package. + required: false runs: using: docker image: Dockerfile diff --git a/build.sh b/build.sh index 8ea6781..42fa433 100755 --- a/build.sh +++ b/build.sh @@ -8,6 +8,7 @@ package=$INPUT_PACKAGE username=$INPUT_USERNAME password=$INPUT_PASSWORD files=$INPUT_FILES +commit_message=$INPUT_COMMIT_MESSAGE assert_non_empty() { name=$1 @@ -44,11 +45,16 @@ echo "::endgroup::" echo "::group::Copying files into $project/$package" cd $GITHUB_WORKSPACE -cp -rt "$HOME/$project/$package" $files +cp -rvt "$HOME/$project/$package" $files echo "::endgroup::" echo "::group::Publishing to OBS" + cd $HOME/$project/$package osc addremove -osc commit -m "OBS release: git#${GITHUB_SHA}" +if [[ -z "$commit_message" ]]; then + osc commit -m "OBS release: git#${GITHUB_SHA}" +else + osc commit -m "$commit_message" +fi echo "::endgroup::" From df1959b29bf2fc216615d3e59ba9ce15b8566ea1 Mon Sep 17 00:00:00 2001 From: Kevin Date: Sun, 17 Oct 2021 09:59:49 +0800 Subject: [PATCH 8/9] update doc --- .github/FUNDING.yml | 2 ++ README.md | 57 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..75c8f61 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,2 @@ +ko_fi: yuezk +custom: ["https://buymeacoffee.com/yuezk", "https://paypal.me/zongkun"] diff --git a/README.md b/README.md index f761e10..00dd178 100644 --- a/README.md +++ b/README.md @@ -1 +1,56 @@ -# publish-obs-package \ No newline at end of file +# Publish OBS Package + +GitHub action to publish the OBS ([Open Build Service](https://openbuildservice.org/)) packages. + +## Inputs + +### `api` + +**Optional** The OBS API url. Default `https://api.opensuse.org` + +### `project` + +**Required** The OBS project name. E.g., `home:yuezk` + +### `package` + +**Required** The OBS package name. E.g., `globalprotect-openconnect` + +### `username` + +**Required** The OBS username. + +### `password` + +**Required** The OBS password. + +### `files` + +**Required** The OBS package files to be submitted. + +Newline-separated glob patterns, which will be expanded by bash when copying the files to the package. + +### `commit_message` + +**Optional** Commit message to use when submitting the package. Default: `OBS release: git#${GITHUB_SHA}"` + +## Example usage + +```yml +name: Publish OBS package +uses: yuezk/publish-obs-package@main +with: + project: yuezk + package: globalprotect-openconnect + username: yuezk + password: ${{ secrets.OBS_PASSWORD }} + files: ./artifacts/obs/* +``` + +## Real-world applications + +- [GlobalProtect-openconnect](https://github.com/yuezk/GlobalProtect-openconnect): A GlobalProtect VPN client (GUI) for Linux based on OpenConnect and built with Qt5, supports SAML auth mode. + +## LICENSE + +[MIT](./LICENSE) From 3a1545db851a83b509c4619e8ce45fa0e7d9abb1 Mon Sep 17 00:00:00 2001 From: Kevin Date: Sun, 17 Oct 2021 10:07:08 +0800 Subject: [PATCH 9/9] update doc --- README.md | 5 ++--- action.yml | 3 +++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 00dd178..04b321e 100644 --- a/README.md +++ b/README.md @@ -26,9 +26,8 @@ GitHub action to publish the OBS ([Open Build Service](https://openbuildservice. ### `files` -**Required** The OBS package files to be submitted. - -Newline-separated glob patterns, which will be expanded by bash when copying the files to the package. +**Required** The OBS package files to be submitted. +Support the newline-separated glob patterns, which will be expanded by bash when copying the files to the package. ### `commit_message` diff --git a/action.yml b/action.yml index af65026..679224e 100644 --- a/action.yml +++ b/action.yml @@ -1,5 +1,8 @@ name: 'publish-obs-package' description: 'Publish an OBS package' +branding: + color: green + icon: package inputs: api: description: OBS API url