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 27, 2024
1 parent 714bd65 commit a160dd1
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 20 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
40 changes: 25 additions & 15 deletions .github/workflows/obs-staging-shared.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,25 @@ 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"
else
echo "OBS_PROJECT=${{ vars.OBS_PROJECT }}" >> "$GITHUB_OUTPUT"
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,19 +74,19 @@ 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 }}"
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
Expand All @@ -85,30 +95,30 @@ jobs:
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
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
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
4 changes: 3 additions & 1 deletion puppeteer/package/_service
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
<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>
<param name="revision">master</param>
<param name="subdir">puppeteer</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 a160dd1

Please sign in to comment.