Skip to content

Commit

Permalink
Submit the code from "release" branch to a separate OBS project
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Sep 30, 2024
1 parent 714bd65 commit a23e8fc
Show file tree
Hide file tree
Showing 14 changed files with 85 additions and 24 deletions.
1 change: 1 addition & 0 deletions .github/workflows/obs-staging-autoinstallation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
push:
branches:
- master
- release
paths:
# run only when an autoinstallation source is changed
- autoinstallation/**
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/obs-staging-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
push:
branches:
- master
- release
paths:
# run only when a source file is changed
- puppeteer/**
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/obs-staging-live.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
push:
branches:
- master
- release
paths:
# run only when a live ISO source is changed
- live/**
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/obs-staging-products.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
push:
branches:
- master
- release
paths:
# run only when a Rust source is changed
- products.d/**
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/obs-staging-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
push:
branches:
- master
- release
paths:
# run only when a Rust source is changed
- rust/**
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/obs-staging-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
push:
branches:
- master
- release
paths:
# run only when a service source is changed
- service/**
Expand Down
46 changes: 29 additions & 17 deletions .github/workflows/obs-staging-shared.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,27 @@ on:

jobs:
update_staging_package:
# do not run in forks which do not set the OBS_PROJECT variable
if: vars.OBS_PROJECT != ''
# do not run in forks which do not set the OBS_PROJECT variable,
# for the "release" branch or a git tag use the OBS_PROJECT_RELEASE variable
if: vars.OBS_PROJECT != '' || ((github.ref_name == 'release' || github.ref_type == 'tag') && vars.OBS_PROJECT_RELEASE != '')

runs-on: ubuntu-latest

container:
image: registry.opensuse.org/opensuse/tumbleweed:latest

steps:
- name: Select OBS project
id: obs_project
run: |-
if [ "${{ github.ref_name }}" = "release" -o "${{ github.ref_type }}" = "tag" ]; then
echo "OBS_PROJECT=${{ vars.OBS_PROJECT_RELEASE }}" >> "$GITHUB_OUTPUT"
echo "OBS project: ${{ vars.OBS_PROJECT_RELEASE }}"
else
echo "OBS_PROJECT=${{ vars.OBS_PROJECT }}" >> "$GITHUB_OUTPUT"
echo "OBS project: ${{ vars.OBS_PROJECT }}"
fi
- name: Configure and refresh repositories
# disable unused repositories to have a faster refresh
run: zypper modifyrepo -d repo-non-oss repo-openh264 repo-update && zypper ref
Expand Down Expand Up @@ -64,51 +76,51 @@ jobs:
OBS_USER: ${{ secrets.OBS_USER }}
OBS_PASSWORD: ${{ secrets.OBS_PASSWORD }}

- name: Checkout ${{ vars.OBS_PROJECT }} ${{ inputs.package_name }}
run: osc co ${{ vars.OBS_PROJECT }} ${{ inputs.package_name }}
- name: Checkout ${{ steps.obs_project.outputs.OBS_PROJECT }} ${{ inputs.package_name }}
run: osc co ${{ steps.obs_project.outputs.OBS_PROJECT }} ${{ inputs.package_name }}

- name: Configure git
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"

- name: Update service revision
# only when a tag has been pushed
if: ${{ github.ref_type == 'tag' }}
# only when a tag has been pushed, or "release" branch updated
if: github.ref_type == 'tag' || github.ref_name == 'release'
run: |-
echo "Updating revision to ${{ github.ref_name }}"
echo "Updating revision to \"${{ github.ref_name }}\""
sed -i -e 's#<param name="revision">.*</param>#<param name="revision">${{ github.ref_name }}</param>#' _service
working-directory: ./${{ vars.OBS_PROJECT }}/${{ inputs.package_name }}
working-directory: ./${{ steps.obs_project.outputs.OBS_PROJECT }}/${{ inputs.package_name }}

- name: Copy optional service file
# patch the URL in the file so it works also from forks, forks also by
# default do not inherit the tags so remove the version format option if
# no tag is present
if: inputs.service_file != ''
run: |
sed -e 's#<param name="url">.*</param>#<param name="url">https://github.com/${{ github.repository }}.git</param>#' ${{ inputs.service_file }} > ./${{ vars.OBS_PROJECT }}/${{ inputs.package_name }}/_service
if [ -z "$(git tag -l)" ]; then sed -i -e 's#<param name="versionformat">.*</param>##' ./${{ vars.OBS_PROJECT }}/${{ inputs.package_name }}/_service; fi
sed -e 's#<param name="url">.*</param>#<param name="url">https://github.com/${{ github.repository }}.git</param>#' ${{ inputs.service_file }} > ./${{ steps.obs_project.outputs.OBS_PROJECT }}/${{ inputs.package_name }}/_service
if [ -z "$(git tag -l)" ]; then sed -i -e 's#<param name="versionformat">.*</param>##' ./${{ steps.obs_project.outputs.OBS_PROJECT }}/${{ inputs.package_name }}/_service; fi
- name: Run services
run: osc service manualrun
working-directory: ./${{ vars.OBS_PROJECT }}/${{ inputs.package_name }}
working-directory: ./${{ steps.obs_project.outputs.OBS_PROJECT }}/${{ inputs.package_name }}

- name: Cleanup
# sometimes the "osc service" run does not cleanup properly all
# downloaded NPM package tarballs and they are accidentally added to the
# OBS package, so delete any TGZ files present
run: rm -vf *.tgz
working-directory: ./${{ vars.OBS_PROJECT }}/${{ inputs.package_name }}
working-directory: ./${{ steps.obs_project.outputs.OBS_PROJECT }}/${{ inputs.package_name }}

- name: Check status
run: osc addremove && osc diff && osc status
working-directory: ./${{ vars.OBS_PROJECT }}/${{ inputs.package_name }}
working-directory: ./${{ steps.obs_project.outputs.OBS_PROJECT }}/${{ inputs.package_name }}

- name: Commit ${{ inputs.package_name }} to ${{ vars.OBS_PROJECT }}
- name: Commit ${{ inputs.package_name }} to ${{ steps.obs_project.outputs.OBS_PROJECT }}
run: |-
osc commit -m "Updated to $(sed -e '/^version:/!d' -e 's/version: *\(.*\)/\1/' agama.obsinfo) ($(sed -e '/^commit:/!d' -e 's/commit: *\(.*\)/\1/' agama.obsinfo))"
working-directory: ./${{ vars.OBS_PROJECT }}/${{ inputs.package_name }}
working-directory: ./${{ steps.obs_project.outputs.OBS_PROJECT }}/${{ inputs.package_name }}

- name: Submit the package
# only when a tag has been pushed
if: ${{ github.ref_type == 'tag' }}
if: github.ref_type == 'tag'
run: osc sr --yes -m "Releasing version ${{ github.ref_name }}"
working-directory: ./${{ vars.OBS_PROJECT }}/${{ inputs.package_name }}
working-directory: ./${{ steps.obs_project.outputs.OBS_PROJECT }}/${{ inputs.package_name }}
1 change: 1 addition & 0 deletions .github/workflows/obs-staging-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
push:
branches:
- master
- release
paths:
# run only when a web frontend source is changed
- web/**
Expand Down
6 changes: 5 additions & 1 deletion autoinstallation/package/_service
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<services>
<service name="obs_scm" mode="manual">
<param name="url">https://github.com/openSUSE/agama.git</param>
<!-- the URL is modified by the .github/workflows/obs-staging-shared.yml
action when submitting to OBS -->
<param name="url">https://github.com/agama-project/agama.git</param>
<param name="versionformat">@PARENT_TAG@+@TAG_OFFSET@</param>
<param name="versionrewrite-pattern">v(.*)</param>
<param name="scm">git</param>
<!-- the revision might be changed to "release" branch or a git tag by the
.github/workflows/obs-staging-shared.yml action when submitting to OBS -->
<param name="revision">master</param>
<param name="subdir">autoinstallation</param>
<param name="without-version">enable</param>
Expand Down
26 changes: 24 additions & 2 deletions doc/obs_integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
- [GitHub Fork](#github-fork)
- [Configuring the GitHub Actions](#configuring-the-github-actions)
- [Triggering the Rebuild](#triggering-the-rebuild)
- [Package Versioning](#package-versioning)
- [Devel Package Versioning](#devel-package-versioning)
- [Release Project](#release-project)
- [Release Package Versioning](#release-package-versioning)

---

Expand Down Expand Up @@ -183,11 +185,31 @@ Alternatively you can trigger the package submission manually. Go to the
bar and in the main area click the "Run workflow" selector. Then in the popup
keep the default `master` branch and click the "Run workflow" button.

## Package Versioning
### Devel Package Versioning

The packages in the Devel project use a version built from the last released
version with a number of commits in the `master` branch since that release.

The version is automatically constructed by the OBS service, for the
`rubygem-agama` package the version is built using the `git describe --tags`
command.

## Release Project

For relasing a public version of Agama we use the
[systemsmanagement:Agama:Release](
https://build.opensuse.org/project/show/systemsmanagement:Agama:Devel) project
and respective [release](https://github.com/agama-project/agama/tree/release)
branch in Git. The reason for a separate project is that we might need to
release a hot fix but the `master` branch might already contain a new feature
for the next version.

The integration works the same way as for the Devel project above, the only
difference is that it uses the `OBS_PROJECT_RELEASE` GitHub Action variable
to define the target OBS project to allow submitting to a different project.

### Release Package Versioning

The packages in the Release project use a version based on the version tag
matching `v[0-9]+`. Use `rake tag` command for creating a tag. See more details
in the [packaging documentation](../PACKAGING.md#bumping-the-version).
6 changes: 5 additions & 1 deletion products.d/_service
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<services>
<service name="obs_scm" mode="manual">
<param name="url">https://github.com/openSUSE/agama.git</param>
<!-- the URL is modified by the .github/workflows/obs-staging-shared.yml
action when submitting to OBS -->
<param name="url">https://github.com/agama-project/agama.git</param>
<param name="versionformat">@PARENT_TAG@+@TAG_OFFSET@</param>
<param name="versionrewrite-pattern">v(.*)</param>
<param name="scm">git</param>
<!-- the revision might be changed to "release" branch or a git tag by the
.github/workflows/obs-staging-shared.yml action when submitting to OBS -->
<param name="revision">master</param>
<param name="subdir">products.d</param>
<param name="without-version">enable</param>
Expand Down
6 changes: 5 additions & 1 deletion puppeteer/package/_service
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
<service name="obs_scm" mode="manual">
<param name="versionformat">@PARENT_TAG@+@TAG_OFFSET@</param>
<param name="versionrewrite-pattern">v(.*)</param>
<param name="url">https://github.com/openSUSE/agama.git</param>
<!-- the URL is modified by the .github/workflows/obs-staging-shared.yml
action when submitting to OBS -->
<param name="url">https://github.com/agama-project/agama.git</param>
<param name="scm">git</param>
<!-- the revision might be changed to "release" branch or a git tag by the
.github/workflows/obs-staging-shared.yml action when submitting to OBS -->
<param name="revision">master</param>
<param name="subdir">puppeteer</param>
<param name="without-version">enable</param>
Expand Down
6 changes: 5 additions & 1 deletion rust/package/_service
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<services>
<service name="obs_scm" mode="manual">
<param name="url">https://github.com/openSUSE/agama.git</param>
<!-- the URL is modified by the .github/workflows/obs-staging-shared.yml
action when submitting to OBS -->
<param name="url">https://github.com/agama-project/agama.git</param>
<param name="versionformat">@PARENT_TAG@+@TAG_OFFSET@</param>
<param name="versionrewrite-pattern">v(.*)</param>
<param name="scm">git</param>
<!-- the revision might be changed to "release" branch or a git tag by the
.github/workflows/obs-staging-shared.yml action when submitting to OBS -->
<param name="revision">master</param>
<param name="subdir">rust</param>
<param name="without-version">enable</param>
Expand Down
6 changes: 5 additions & 1 deletion web/package/_service
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
<service name="obs_scm" mode="manual">
<param name="versionformat">@PARENT_TAG@+@TAG_OFFSET@</param>
<param name="versionrewrite-pattern">v(.*)</param>
<param name="url">https://github.com/openSUSE/agama.git</param>
<!-- the URL is modified by the .github/workflows/obs-staging-shared.yml
action when submitting to OBS -->
<param name="url">https://github.com/agama-project/agama.git</param>
<param name="scm">git</param>
<!-- the revision might be changed to "release" branch or a git tag by the
.github/workflows/obs-staging-shared.yml action when submitting to OBS -->
<param name="revision">master</param>
<param name="subdir">web</param>
<param name="without-version">enable</param>
Expand Down

0 comments on commit a23e8fc

Please sign in to comment.