name: custom release permissions: contents: write on: push: branches: - main paths: - ".github/workflows/custom-release.yml" - "patches/**" - "scripts/update-custom-release.sh" - "scripts/sync-upstream.sh" workflow_dispatch: inputs: upstream_tag: description: "Optional upstream Syncthing tag, for example v2.1.3" required: false suffix: description: "Optional custom release suffix, for example stignore.7" required: false schedule: - cron: "17 04 * * *" jobs: build-custom-release: runs-on: macos-14 steps: - name: Check out repository uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Go uses: actions/setup-go@v5 with: go-version-file: go.mod cache: false - name: Configure Git author run: | git config user.name "GitHub Actions" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - name: Mirror upstream and rebuild patched main run: ./scripts/sync-upstream.sh env: SYNC_REMOTE: origin - name: Build patched Syncthing release run: | case "$(uname -m)" in arm64) darwin_arch=arm64 ;; x86_64) darwin_arch=amd64 ;; *) echo "Unsupported macOS runner architecture: $(uname -m)" >&2; exit 1 ;; esac export CUSTOM_RELEASE_BUILDS="darwin/$darwin_arch/zip/1 linux/amd64/tar/0 linux/arm64/tar/0" ./scripts/update-custom-release.sh env: CUSTOM_RELEASE_UPSTREAM_TAG: ${{ github.event.inputs.upstream_tag }} CUSTOM_RELEASE_SUFFIX: ${{ github.event.inputs.suffix }} CUSTOM_RELEASE_PUSH: "1" CUSTOM_RELEASE_PUSH_BRANCH: "0" CUSTOM_RELEASE_REMOTE: origin CUSTOM_RELEASE_SIGN_DARWIN: "0" CUSTOM_RELEASE_CREATE_GITEA_RELEASE: "0" GH_TOKEN: ${{ github.token }} - name: Publish GitHub release run: | tag="${CUSTOM_RELEASE_UPSTREAM_TAG:-$(git ls-remote --refs --tags --sort='version:refname' https://github.com/syncthing/syncthing.git 'v[0-9]*' | awk '{ tag = $2; sub("refs/tags/", "", tag); if (tag ~ /^v[0-9]+\.[0-9]+\.[0-9]+$/) latest = tag } END { print latest }')}-$CUSTOM_RELEASE_SUFFIX" if gh release view "$tag" >/dev/null 2>&1; then echo "GitHub release $tag already exists; nothing to do." exit 0 fi assets=() for asset in dist/*; do [ -f "$asset" ] || continue [ "$(basename "$asset")" = release-notes.md ] && continue assets+=("$asset") done gh release create "$tag" "${assets[@]}" --title "$tag" --notes-file dist/release-notes.md --verify-tag env: CUSTOM_RELEASE_UPSTREAM_TAG: ${{ github.event.inputs.upstream_tag }} CUSTOM_RELEASE_SUFFIX: ${{ github.event.inputs.suffix || 'stignore.7' }} GH_TOKEN: ${{ github.token }}