{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 177
Add pending intent to foreground worker notification #102
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release After Merge | |
| on: | |
| pull_request: | |
| types: | |
| - closed | |
| branches: | |
| - master | |
| jobs: | |
| release: | |
| if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/') | |
| uses: ./.github/workflows/build-and-release.yml | |
| with: | |
| release_ref: master | |
| publish_release: true | |
| prerelease: true | |
| secrets: inherit | |
| fdroid-mr: | |
| if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/') | |
| needs: release | |
| runs-on: ubuntu-latest | |
| env: | |
| FDROID_FORK: ${{ vars.FDROID_GITLAB_FORK }} | |
| FDROID_TARGET: ${{ vars.FDROID_GITLAB_TARGET != '' && vars.FDROID_GITLAB_TARGET || 'fdroid/fdroiddata' }} | |
| PR_URL: ${{ github.event.pull_request.html_url }} | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| steps: | |
| - name: Validate configuration | |
| id: cfg | |
| shell: bash | |
| env: | |
| TOKEN: ${{ secrets.FDROID_GITLAB_TOKEN }} | |
| run: | | |
| set -euo pipefail | |
| missing=0 | |
| if [[ -z "${FDROID_FORK:-}" ]]; then | |
| echo "::warning title=FDroid MR skipped::Set repository variable FDROID_GITLAB_FORK (e.g. user/fdroiddata)." | |
| missing=1 | |
| fi | |
| if [[ -z "${TOKEN:-}" ]]; then | |
| echo "::warning title=FDroid MR skipped::Set secret FDROID_GITLAB_TOKEN with a GitLab PAT (api scope)." | |
| missing=1 | |
| fi | |
| if [[ $missing -ne 0 ]]; then | |
| echo "ready=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "ready=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Check out repository | |
| if: steps.cfg.outputs.ready == 'true' | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: master | |
| - name: Determine release version | |
| if: steps.cfg.outputs.ready == 'true' | |
| id: version | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| python3 <<'PY' | |
| import os | |
| import pathlib | |
| import re | |
| gradle = pathlib.Path("presentation/build.gradle").read_text() | |
| code_match = re.search(r"^\s*versionCode\s+(\d+)", gradle, re.MULTILINE) | |
| name_match = re.search(r"^\s*versionName\s+['\"]([\d\.]+)['\"]", gradle, re.MULTILINE) | |
| if not code_match or not name_match: | |
| raise SystemExit("Unable to read versionCode/versionName from presentation/build.gradle") | |
| version_name = name_match.group(1) | |
| version_code = code_match.group(1) | |
| branch = f"fdroid-release-v{version_name}" | |
| out = pathlib.Path(os.environ["GITHUB_OUTPUT"]) | |
| out.write_text(f"version_name={version_name}\nversion_code={version_code}\nbranch_name={branch}\n") | |
| PY | |
| - name: Sync fdroiddata fork | |
| if: steps.cfg.outputs.ready == 'true' | |
| env: | |
| TOKEN: ${{ secrets.FDROID_GITLAB_TOKEN }} | |
| BRANCH_NAME: ${{ steps.version.outputs.branch_name }} | |
| run: | | |
| set -euo pipefail | |
| git clone "https://oauth2:${TOKEN}@gitlab.com/${FDROID_FORK}.git" fdroiddata | |
| cd fdroiddata | |
| git remote add upstream "https://gitlab.com/${FDROID_TARGET}.git" | |
| git fetch upstream master | |
| git checkout -B "${BRANCH_NAME}" upstream/master | |
| - name: Update metadata | |
| if: steps.cfg.outputs.ready == 'true' | |
| env: | |
| BRANCH_NAME: ${{ steps.version.outputs.branch_name }} | |
| run: | | |
| set -euo pipefail | |
| cp fdroid/metadata/dev.octoshrimpy.quik.yml fdroiddata/metadata/dev.octoshrimpy.quik.yml | |
| cd fdroiddata | |
| if git diff --quiet; then | |
| echo "no_changes=true" >> "$GITHUB_ENV" | |
| else | |
| echo "no_changes=false" >> "$GITHUB_ENV" | |
| fi | |
| - name: Commit and push metadata update | |
| if: steps.cfg.outputs.ready == 'true' && env.no_changes == 'false' | |
| env: | |
| TOKEN: ${{ secrets.FDROID_GITLAB_TOKEN }} | |
| VERSION_NAME: ${{ steps.version.outputs.version_name }} | |
| BRANCH_NAME: ${{ steps.version.outputs.branch_name }} | |
| run: | | |
| set -euo pipefail | |
| cd fdroiddata | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add metadata/dev.octoshrimpy.quik.yml | |
| git commit -m "Update QUIK to v${VERSION_NAME}" | |
| git push --force-with-lease origin "${BRANCH_NAME}" | |
| - name: Create GitLab Merge Request | |
| if: steps.cfg.outputs.ready == 'true' && env.no_changes == 'false' | |
| env: | |
| TOKEN: ${{ secrets.FDROID_GITLAB_TOKEN }} | |
| BRANCH_NAME: ${{ steps.version.outputs.branch_name }} | |
| VERSION_NAME: ${{ steps.version.outputs.version_name }} | |
| PR_URL: ${{ env.PR_URL }} | |
| TARGET_PROJECT: ${{ env.FDROID_TARGET }} | |
| FORK_PROJECT: ${{ env.FDROID_FORK }} | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| python3 <<'PY' | |
| import json | |
| import os | |
| import urllib.parse | |
| import urllib.request | |
| import sys | |
| token = os.environ["TOKEN"] | |
| branch = os.environ["BRANCH_NAME"] | |
| version = os.environ["VERSION_NAME"] | |
| pr_url = os.environ["PR_URL"] | |
| target = os.environ["TARGET_PROJECT"] | |
| fork = os.environ["FORK_PROJECT"] | |
| headers = {"PRIVATE-TOKEN": token, "Content-Type": "application/x-www-form-urlencoded"} | |
| def project_id(path): | |
| url = f"https://gitlab.com/api/v4/projects/{urllib.parse.quote(path, safe='')}" | |
| req = urllib.request.Request(url, headers=headers) | |
| with urllib.request.urlopen(req) as resp: | |
| return json.loads(resp.read())["id"] | |
| target_id = project_id(target) | |
| fork_id = project_id(fork) | |
| # Check for an existing open MR from this branch | |
| params = urllib.parse.urlencode({ | |
| "source_branch": branch, | |
| "state": "opened", | |
| "source_project_id": fork_id, | |
| }) | |
| req = urllib.request.Request( | |
| f"https://gitlab.com/api/v4/projects/{target_id}/merge_requests?{params}", | |
| headers=headers, | |
| ) | |
| with urllib.request.urlopen(req) as resp: | |
| existing = json.loads(resp.read()) | |
| if existing: | |
| print("Merge request already exists:", existing[0]["web_url"]) | |
| sys.exit(0) | |
| description = ( | |
| f"Automated update after {pr_url}\n\n" | |
| f"GitHub release: https://github.com/octoshrimpy/quik/releases/tag/v{version}" | |
| ) | |
| payload = urllib.parse.urlencode({ | |
| "source_branch": branch, | |
| "target_branch": "master", | |
| "title": f"Update QUIK to v{version}", | |
| "description": description, | |
| "source_project_id": fork_id, | |
| }).encode() | |
| req = urllib.request.Request( | |
| f"https://gitlab.com/api/v4/projects/{target_id}/merge_requests", | |
| data=payload, | |
| headers=headers, | |
| ) | |
| with urllib.request.urlopen(req) as resp: | |
| data = json.loads(resp.read()) | |
| print("Created merge request:", data["web_url"]) | |
| PY |
You can’t perform that action at this time.
