-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
166 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ko_fi: yuezk | ||
custom: ["https://buymeacoffee.com/yuezk", "https://paypal.me/zongkun"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FROM opensuse/leap | ||
|
||
RUN zypper ref && zypper in -y osc | ||
|
||
COPY entrypoint.sh /entrypoint.sh | ||
COPY build.sh /build.sh | ||
|
||
ENTRYPOINT ["/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,55 @@ | ||
# publish-obs-package | ||
# 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. | ||
Support the 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: 'publish-obs-package' | ||
description: 'Publish an OBS package' | ||
branding: | ||
color: green | ||
icon: package | ||
inputs: | ||
api: | ||
description: OBS API url | ||
required: false | ||
default: https://api.opensuse.org | ||
project: | ||
description: OBS project name | ||
required: true | ||
package: | ||
description: OBS package name | ||
required: true | ||
username: | ||
description: OBS username | ||
required: true | ||
password: | ||
description: OBS password | ||
required: true | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/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 | ||
commit_message=$INPUT_COMMIT_MESSAGE | ||
|
||
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 <<EOF | ||
[general] | ||
apiurl=$api | ||
[$api] | ||
user = $username | ||
pass = $password | ||
EOF | ||
echo "::endgroup::" | ||
|
||
echo "::group::Checkouting package" | ||
cd $HOME | ||
osc checkout $project $package | ||
echo "::endgroup::" | ||
|
||
echo "::group::Copying files into $project/$package" | ||
cd $GITHUB_WORKSPACE | ||
cp -rvt "$HOME/$project/$package" $files | ||
echo "::endgroup::" | ||
|
||
echo "::group::Publishing to OBS" | ||
|
||
cd $HOME/$project/$package | ||
osc addremove | ||
if [[ -z "$commit_message" ]]; then | ||
osc commit -m "OBS release: git#${GITHUB_SHA}" | ||
else | ||
osc commit -m "$commit_message" | ||
fi | ||
echo "::endgroup::" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/sh -l | ||
|
||
set -o errexit -o pipefail -o nounset | ||
|
||
echo '::group::Creating builder user' | ||
useradd --create-home --shell /bin/bash builder | ||
passwd --delete builder | ||
echo '::endgroup::' | ||
|
||
exec runuser builder --command 'bash -l -c /build.sh' |