Georges Basile Stavracas Neto 36f06e07c6 CI: Split Flatpak beta and stable branches
We currently publish the same build from the same branch
to Flathub. However, soon we'll need to build the Flatpak
manifest in different branches, and publish them in different
repositories.

Prepare for that by splitting the publish step in two: one
for Flathub, and another for Flathub Beta. Do that using
a matrix strategy.

Skip building and publishing stable releases when it's a beta
or RC release by setting an output variable in the first job.
2021-12-30 17:05:58 -03:00

131 lines
4.8 KiB
YAML

---
name: Flatpak
on:
push:
paths-ignore: ['**.md']
branches: [master, 'release/**']
pull_request:
paths-ignore: ['**.md']
branches: [master, 'release/**']
release:
types: [published]
branches: [master, 'release/**']
env:
TWITCH_CLIENTID: ${{ secrets.TWITCH_CLIENT_ID }}
TWITCH_HASH: ${{ secrets.TWITCH_HASH }}
RESTREAM_CLIENTID: ${{ secrets.RESTREAM_CLIENTID }}
RESTREAM_HASH: ${{ secrets.RESTREAM_HASH }}
YOUTUBE_CLIENTID: ${{ secrets.YOUTUBE_CLIENTID }}
YOUTUBE_CLIENTID_HASH: ${{ secrets.YOUTUBE_CLIENTID_HASH }}
YOUTUBE_SECRET: ${{ secrets.YOUTUBE_SECRET }}
YOUTUBE_SECRET_HASH: ${{ secrets.YOUTUBE_SECRET_HASH }}
jobs:
generate_bundle:
name: Generate Flatpak Bundle
runs-on: [ubuntu-latest]
if: github.event_name != 'release'
container:
image: bilelmoussaoui/flatpak-github-actions:kde-5.15-21.08
options: --privileged
steps:
- name: 'Check for Github Labels'
if: github.event_name == 'pull_request'
shell: bash
run: |
LABELS_URL="$(echo ${{ github.event.pull_request.url }} | sed s'/pulls/issues/')"
LABEL_FOUND="$(curl -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "${LABELS_URL}/labels" | sed -n 's/.*"name": "\(.*\)",/\1/p' | grep 'Seeking Testers' || true)"
if [ "${LABEL_FOUND}" = "Seeking Testers" ]; then
echo "SEEKING_TESTERS=1" >> $GITHUB_ENV
else
echo "SEEKING_TESTERS=0" >> $GITHUB_ENV
fi
- name: Checkout
uses: actions/checkout@v2.3.3
if: success() && (github.event_name != 'pull_request' || env.SEEKING_TESTERS == '1')
with:
submodules: 'recursive'
- name: Build Flatpak Manifest
uses: bilelmoussaoui/flatpak-github-actions/flatpak-builder@v4
if: success() && (github.event_name != 'pull_request' || env.SEEKING_TESTERS == '1')
with:
bundle: obs-studio-${{ github.sha }}.flatpak
manifest-path: CI/flatpak/com.obsproject.Studio.json
cache-key: flatpak-builder-${{ github.sha }}
publish:
name: Publish to Flathub
runs-on: [ubuntu-latest]
if: github.event_name == 'release'
env:
FLATPAK_BUILD_PATH: flatpak_app/files/share
container:
image: bilelmoussaoui/flatpak-github-actions:kde-5.15-21.08
options: --privileged
strategy:
matrix:
branch: [stable, beta]
steps:
- name: Check if job should run
id: should_run
if: "${{ matrix.branch != 'stable' || (!contains(github.ref, '-beta') && !contains(github.ref, '-rc')) }}"
run: |
echo "::set-output name=should_run::yes"
- name: Checkout
uses: actions/checkout@v2.3.3
if: steps.should_run.outputs.should_run == 'yes'
with:
submodules: 'recursive'
- name: Build Flatpak Manifest
uses: bilelmoussaoui/flatpak-github-actions/flatpak-builder@master
if: steps.should_run.outputs.should_run == 'yes'
with:
bundle: obs-studio-${{ github.sha }}.flatpak
manifest-path: CI/flatpak/com.obsproject.Studio.json
cache-key: flatpak-builder-${{ github.sha }}
mirror-screenshots-url: https://dl.flathub.org/repo/screenshots
branch: ${{ matrix.branch }}
- name: Validate AppStream
shell: bash
working-directory: ${{ env.FLATPAK_BUILD_PATH }}
if: steps.should_run.outputs.should_run == 'yes'
run: |
appstream-util validate appdata/com.obsproject.Studio.appdata.xml
- name: Verify icon and metadata in app-info
shell: bash
working-directory: ${{ env.FLATPAK_BUILD_PATH }}
if: steps.should_run.outputs.should_run == 'yes'
run: |
test -f app-info/icons/flatpak/128x128/com.obsproject.Studio.png || { echo "Missing 128x128 icon in app-info" ; exit 1; }
test -f app-info/xmls/com.obsproject.Studio.xml.gz || { echo "Missing com.obsproject.Studio.xml.gz in app-info" ; exit 1; }
- name: Commit screenshots to the OSTree repository
if: steps.should_run.outputs.should_run == 'yes'
run: |
ostree commit --repo=repo --canonical-permissions --branch=screenshots/x86_64 flatpak_app/screenshots
- name: Publish to Flathub Beta
uses: bilelmoussaoui/flatpak-github-actions/flat-manager@v4
if: steps.should_run.outputs.should_run == 'yes' && matrix.branch == 'beta'
with:
flat-manager-url: https://hub.flathub.org/
repository: beta
token: ${{ secrets.FLATHUB_BETA_TOKEN }}
- name: Publish to Flathub
uses: bilelmoussaoui/flatpak-github-actions/flat-manager@v4
if: steps.should_run.outputs.should_run == 'yes' && matrix.branch == 'stable'
with:
flat-manager-url: https://hub.flathub.org/
repository: stable
token: ${{ secrets.FLATHUB_TOKEN }}