Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
yuezk committed Oct 17, 2021
2 parents 0238f56 + 3a1545d commit 6e58274
Show file tree
Hide file tree
Showing 6 changed files with 166 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
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"]
8 changes: 8 additions & 0 deletions Dockerfile
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"]
56 changes: 55 additions & 1 deletion README.md
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)
31 changes: 31 additions & 0 deletions action.yml
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
60 changes: 60 additions & 0 deletions build.sh
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::"
10 changes: 10 additions & 0 deletions entrypoint.sh
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'

0 comments on commit 6e58274

Please sign in to comment.