Skip to content

Commit

Permalink
Automatically release a new version
Browse files Browse the repository at this point in the history
when a version tag is created
  • Loading branch information
lslezak committed Jun 12, 2023
1 parent 8579be3 commit 2dfef37
Show file tree
Hide file tree
Showing 8 changed files with 164 additions and 53 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/obs-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Release

on:
# runs when creating a release tag
push:
tags:
# use a more specific pattern when a maintenance version is branched
- v[0-9]+.**

jobs:
# Note: cockpit-agama-playwright is currently not submitted

update_rust:
uses: ./.github/workflows/obs-staging-shared.yml
# pass all secrets
secrets: inherit
with:
install_packages: obs-service-cargo_audit obs-service-cargo_vendor
project_name: systemsmanagement:Agama:Devel
package_name: agama-cli

update_web:
uses: ./.github/workflows/obs-staging-shared.yml
# pass all secrets
secrets: inherit
with:
install_packages: obs-service-node_modules
project_name: systemsmanagement:Agama:Devel
package_name: cockpit-agama

update_service:
uses: ./.github/workflows/obs-service-shared.yml
# pass all secrets
secrets: inherit
with:
project_name: systemsmanagement:Agama:Devel
73 changes: 73 additions & 0 deletions .github/workflows/obs-service-shared.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Update OBS Service Package

on:
workflow_call:
secrets:
OBS_USER:
required: true
OBS_PASSWORD:
required: true

inputs:
project_name:
description: OBS project name
required: true
type: string

jobs:
update_service:
# do not run in forks
if: github.repository == 'openSUSE/agama'

runs-on: ubuntu-latest

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

steps:
- 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

- name: Install tools
run: zypper --non-interactive install --no-recommends
git
obs-service-format_spec_file
osc
ruby
'rubygem(gem2rpm)'
'rubygem(yast-rake)'

- name: Git Checkout
uses: actions/checkout@v3
with:
# fetch all history, we need to find the latest tag and offset for the version number
fetch-depth: 0

- name: Fix file owner
# workaround for a strict git check
run: chown -R -c 0 .

- name: Configure osc
run: .github/workflows/configure_osc.sh
env:
OBS_USER: ${{ secrets.OBS_USER }}
OBS_PASSWORD: ${{ secrets.OBS_PASSWORD }}

- name: Commit the rubygem-agama package to ${{ inputs.project_name }}
run: rake osc:commit
working-directory: ./service
env:
# do not build the package with "osc", it takes long time
# and does not provide much value
SKIP_OSC_BUILD: 1
OBS_PROJECT: ${{ inputs.project_name }}

- name: Submit the rubygem-agama package
# only when a tag has been pushed
if: ${{ github.ref_type == 'tag' }}
# the package has been comitted in the previous step, just submit it
run: rake osc:sr:force
working-directory: ./service
env:
OBS_PROJECT: ${{ inputs.project_name }}
1 change: 1 addition & 0 deletions .github/workflows/obs-staging-playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ jobs:
# pass all secrets
secrets: inherit
with:
project_name: systemsmanagement:Agama:Staging
package_name: cockpit-agama-playwright
1 change: 1 addition & 0 deletions .github/workflows/obs-staging-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ jobs:
secrets: inherit
with:
install_packages: obs-service-cargo_audit obs-service-cargo_vendor
project_name: systemsmanagement:Agama:Staging
package_name: agama-cli
52 changes: 6 additions & 46 deletions .github/workflows/obs-staging-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,49 +10,9 @@ on:
- service/**

jobs:
update_staging:
# do not run in forks
if: github.repository == 'openSUSE/agama'

runs-on: ubuntu-latest

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

steps:
- 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

- name: Install tools
run: zypper --non-interactive install --no-recommends
git
obs-service-format_spec_file
osc
ruby
'rubygem(gem2rpm)'
'rubygem(yast-rake)'

- name: Git Checkout
uses: actions/checkout@v3
with:
# fetch all history, we need to find the latest tag and offset for the version number
fetch-depth: 0

- name: Fix file owner
# workaround for a strict git check
run: chown -R -c 0 .

- name: Configure osc
run: .github/workflows/configure_osc.sh
env:
OBS_USER: ${{ secrets.OBS_USER }}
OBS_PASSWORD: ${{ secrets.OBS_PASSWORD }}

- name: Commit the rubygem-agama package
run: rake osc:commit
working-directory: ./service
env:
# do not build the package with "osc", it takes long time
# and does not provide much value
SKIP_OSC_BUILD: 1
update_service:
uses: ./.github/workflows/obs-staging-shared.yml
# pass all secrets
secrets: inherit
with:
project_name: systemsmanagement:Agama:Staging
31 changes: 25 additions & 6 deletions .github/workflows/obs-staging-shared.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# this is a shared workflow, not called as a top level workflow

name: Update OBS Staging
name: Update OBS Packages

on:
workflow_call:
Expand All @@ -21,6 +21,11 @@ on:
required: true
type: string

project_name:
description: OBS project name
required: true
type: string

jobs:
update_staging_package:
# do not run in forks
Expand Down Expand Up @@ -55,17 +60,31 @@ jobs:
OBS_PASSWORD: ${{ secrets.OBS_PASSWORD }}

- name: Checkout ${{ inputs.package_name }}
run: osc co systemsmanagement:Agama:Staging ${{ inputs.package_name }}

run: osc co ${{ inputs.project_name }} ${{ inputs.package_name }}

- name: Update service revision
# only when a tag has been pushed
if: ${{ github.ref_type == 'tag' }}
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: ./${{ inputs.project_name }}/${{ inputs.package_name }}

- name: Run services
run: osc service manualrun
working-directory: ./systemsmanagement:Agama:Staging/${{ inputs.package_name }}
working-directory: ./${{ inputs.project_name }}/${{ inputs.package_name }}

- name: Check status
run: osc status
working-directory: ./systemsmanagement:Agama:Staging/${{ inputs.package_name }}
working-directory: ./${{ inputs.project_name }}/${{ inputs.package_name }}

- name: Commit ${{ inputs.package_name }}
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: ./systemsmanagement:Agama:Staging/${{ inputs.package_name }}
working-directory: ./${{ inputs.project_name }}/${{ inputs.package_name }}

- name: Submit the package
# only when a tag has been pushed
if: ${{ github.ref_type == 'tag' }}
run: osc sr --yes -m "Releasing version ${{ github.ref_name }}"
working-directory: ./${{ inputs.project_name }}/${{ 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 @@ -16,4 +16,5 @@ jobs:
secrets: inherit
with:
install_packages: obs-service-node_modules
project_name: systemsmanagement:Agama:Staging
package_name: cockpit-agama
22 changes: 21 additions & 1 deletion doc/obs_integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,27 @@ The [systemsmanagement:Agama:Devel](https://build.opensuse.org/project/show/syst
contains the latest released version of the Agama project. The packages should
be more stable than in the Staging project.

These packages are updated manually when a new version is released.
These packages are updated automatically when a new version is released. See
more details below.

## Releasing a New Version

For leasing a new version just create a new version tag in form `v[0-9]+\..*`
and push it to the server:

```
git tag -a -m "Version 2.3.4" v2.3.4
git push origin v2.3.4
```

The GitHub Actions will publish the packages in the systemsmanagement:Agama:Devel
project and create submit requests to openSUSE Factory.

### Notes

Later when a maintenance branch is created the matching version tag in the
GitHub Action needs to become more specific to correctly submit to Factory
or to a maintenance project.

## OBS Synchronization

Expand Down

0 comments on commit 2dfef37

Please sign in to comment.