Skip to content

0.12.1

0.12.1 #13

Workflow file for this run

name: Update Flathub
on:
push:
tags:
- 'v*'
permissions:
contents: read
jobs:
update-flathub:
runs-on: ubuntu-latest
steps:
- name: Extract tag and commit
id: meta
env:
REPO: ${{ github.server_url }}/${{ github.repository }}
run: |
TAG="${GITHUB_REF#refs/tags/}"
if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$ ]]; then
echo "::error::Invalid tag format: $TAG"
exit 1
fi
# Dereference annotated tag to get commit SHA; falls back for lightweight tags
DEREF=$(git ls-remote "${REPO}.git" "${TAG}^{}" | awk '{print $1}')
if [ -n "$DEREF" ]; then
COMMIT="$DEREF"
else
COMMIT=$(git ls-remote "${REPO}.git" "$TAG" | awk '{print $1}')
fi
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "commit=$COMMIT" >> "$GITHUB_OUTPUT"
- name: Checkout sone at tag
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
ref: ${{ steps.meta.outputs.tag }}
path: sone
persist-credentials: false
- name: Clone Flathub repo
env:
TOKEN: ${{ secrets.FLATHUB_TOKEN }}
run: |
git clone https://github.com/flathub/io.github.lullabyX.sone.git flathub
cd flathub
git config http.https://github.com/.extraheader \
"AUTHORIZATION: basic $(printf '%s' "x-access-token:${TOKEN}" | base64 -w0)"
- name: Check for existing PR
id: check
env:
GH_TOKEN: ${{ secrets.FLATHUB_TOKEN }}
TAG: ${{ steps.meta.outputs.tag }}
run: |
BRANCH="update-${TAG}"
COUNT=$(gh pr list \
--repo flathub/io.github.lullabyX.sone \
--head "$BRANCH" \
--state open --json number --jq 'length')
if [ "$COUNT" -gt 0 ]; then
echo "skip=true" >> "$GITHUB_OUTPUT"
echo "::notice::PR from branch $BRANCH already exists, skipping"
else
echo "skip=false" >> "$GITHUB_OUTPUT"
fi
- name: Update manifest
if: steps.check.outputs.skip != 'true'
working-directory: flathub
env:
TAG: ${{ steps.meta.outputs.tag }}
COMMIT: ${{ steps.meta.outputs.commit }}
run: |
GIT_SRC='.modules[] | select(.name == "sone") | .sources[] | select(.type == "git")'
yq -i "($GIT_SRC).tag = strenv(TAG)" io.github.lullabyX.sone.yml
yq -i "($GIT_SRC).commit = strenv(COMMIT)" io.github.lullabyX.sone.yml
- name: Set up Python
if: steps.check.outputs.skip != 'true'
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: '3.12'
# Pinned to a specific commit for supply chain safety
- name: Clone flatpak-builder-tools
if: steps.check.outputs.skip != 'true'
run: |
git clone --depth 1 https://github.com/flatpak/flatpak-builder-tools.git
cd flatpak-builder-tools
git fetch --depth 1 origin 5de461271d05f43f267b954ac6010b410378ae47
git checkout 5de461271d05f43f267b954ac6010b410378ae47
- name: Regenerate cargo-sources.json
if: steps.check.outputs.skip != 'true'
run: |
pip install tomlkit==0.14.0 aiohttp==3.13.3
python3 flatpak-builder-tools/cargo/flatpak-cargo-generator.py \
sone/src-tauri/Cargo.lock -o flathub/cargo-sources.json
- name: Regenerate node-sources.json
if: steps.check.outputs.skip != 'true'
run: |
pip install ./flatpak-builder-tools/node
flatpak-node-generator npm sone/package-lock.json -o flathub/node-sources.json
- name: Commit and push
if: steps.check.outputs.skip != 'true'
working-directory: flathub
env:
TAG: ${{ steps.meta.outputs.tag }}
run: |
BRANCH="update-${TAG}"
git checkout -b "$BRANCH"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add io.github.lullabyX.sone.yml cargo-sources.json node-sources.json
git commit -m "Update to ${TAG}"
git push -u origin "$BRANCH"
- name: Create pull request
if: steps.check.outputs.skip != 'true'
env:
GH_TOKEN: ${{ secrets.FLATHUB_TOKEN }}
TAG: ${{ steps.meta.outputs.tag }}
REPO_URL: ${{ github.server_url }}/${{ github.repository }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
gh pr create \
--repo flathub/io.github.lullabyX.sone \
--head "update-${TAG}" \
--title "Update to ${TAG}" \
--body "Automated update to [${TAG}](${REPO_URL}/releases/tag/${TAG}).
### Changes
- Updated \`tag\` and \`commit\` in \`io.github.lullabyX.sone.yml\`
- Regenerated \`cargo-sources.json\`
- Regenerated \`node-sources.json\`
---
_Auto-generated by the [flathub-update](${RUN_URL}) workflow._"