Sync opencode-cached Releases #86
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: Sync opencode-cached Releases | |
| on: | |
| schedule: | |
| # Every 8 hours, offset +1h from opencode-cached's schedule (0 */8 * * *) | |
| - cron: '0 1,9,17 * * *' | |
| workflow_dispatch: | |
| inputs: | |
| cached_tag: | |
| description: 'Specific opencode-cached tag to build (e.g., v1.2.27-cached)' | |
| required: false | |
| type: string | |
| permissions: | |
| contents: read | |
| actions: write | |
| jobs: | |
| check-new-release: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| should_build: ${{ steps.check.outputs.should_build }} | |
| version: ${{ steps.check.outputs.version }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check for new opencode-cached release | |
| id: check | |
| run: | | |
| # Get latest opencode-cached release | |
| if [ -n "${{ inputs.cached_tag }}" ]; then | |
| CACHED_TAG="${{ inputs.cached_tag }}" | |
| echo "Using manually specified tag: $CACHED_TAG" | |
| else | |
| CACHED_TAG=$(gh api repos/johnnymo87/opencode-cached/releases/latest --jq .tag_name) | |
| echo "Latest opencode-cached tag: $CACHED_TAG" | |
| fi | |
| # Extract version (strip 'v' prefix and '-cached' suffix) | |
| VERSION=$(echo "$CACHED_TAG" | sed 's/^v//;s/-cached$//') | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| # Check if we already have a patched release for this version | |
| PATCHED_TAG="v${VERSION}-patched" | |
| if gh release view "$PATCHED_TAG" --repo ${{ github.repository }} >/dev/null 2>&1; then | |
| echo "Release $PATCHED_TAG already exists, skipping" | |
| echo "should_build=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "Release $PATCHED_TAG does not exist, will build" | |
| echo "should_build=true" >> $GITHUB_OUTPUT | |
| fi | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| trigger-build: | |
| needs: check-new-release | |
| if: needs.check-new-release.outputs.should_build == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Trigger build workflow | |
| run: | | |
| gh workflow run build-release.yml \ | |
| --repo ${{ github.repository }} \ | |
| --ref main \ | |
| --field version=${{ needs.check-new-release.outputs.version }} | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| - name: Log trigger | |
| run: | | |
| echo "Triggered build for version ${{ needs.check-new-release.outputs.version }}" |