From 4c782728c2589942a850b400aac7323b02d63e4b Mon Sep 17 00:00:00 2001 From: Aodhan Hayter Date: Tue, 2 Sep 2025 21:38:54 -0600 Subject: [PATCH 1/4] Add test workflow to verify scheduling works on branch --- .github/workflows/test-workflow.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/test-workflow.yml diff --git a/.github/workflows/test-workflow.yml b/.github/workflows/test-workflow.yml new file mode 100644 index 0000000..c461b63 --- /dev/null +++ b/.github/workflows/test-workflow.yml @@ -0,0 +1,27 @@ +name: Test Workflow + +on: + push: + branches: [fix-workflow-schedule] + pull_request: + branches: [master] + workflow_dispatch: + schedule: + - cron: '*/15 * * * *' # Every 15 minutes for testing + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Test Schedule + run: | + echo "✅ Workflow is running successfully!" + echo "Trigger: ${{ github.event_name }}" + echo "Time: $(date)" + + - name: Check nix-update availability + run: | + nix --version || echo "Nix not available yet" \ No newline at end of file From 22793760866d8afd83d33591084b66bec06d73bf Mon Sep 17 00:00:00 2001 From: Aodhan Hayter Date: Tue, 2 Sep 2025 21:40:18 -0600 Subject: [PATCH 2/4] Add fixed version of update workflow with proper YAML syntax --- .github/workflows/update-opencode-fixed.yml | 231 ++++++++++++++++++++ 1 file changed, 231 insertions(+) create mode 100644 .github/workflows/update-opencode-fixed.yml diff --git a/.github/workflows/update-opencode-fixed.yml b/.github/workflows/update-opencode-fixed.yml new file mode 100644 index 0000000..6a964a5 --- /dev/null +++ b/.github/workflows/update-opencode-fixed.yml @@ -0,0 +1,231 @@ +name: Update OpenCode (Fixed) + +# IMPORTANT: GitHub scheduled workflows requirements: +# 1. Only runs on the default branch (master/main) +# 2. Automatically disabled after 60 days of repository inactivity +# 3. Must be pushed to default branch before schedule activates +# 4. All times are in UTC +# +# To reactivate after inactivity: +# - Make any commit to the repository +# - Or manually trigger using workflow_dispatch + +on: + schedule: + # Run every 6 hours at 15 minutes past (avoids peak times) + # Times: 00:15, 06:15, 12:15, 18:15 UTC + - cron: '15 */6 * * *' + workflow_dispatch: + inputs: + version: + description: 'Specific version to update to (optional)' + required: false + type: string + push: + branches: [fix-workflow-schedule] # For testing + +permissions: + contents: write + +jobs: + update-opencode: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + + - name: Set up Nix + uses: cachix/install-nix-action@v24 + with: + nix_path: nixpkgs=channel:nixos-unstable + extra_nix_config: | + experimental-features = nix-command flakes + + - name: Install nix-update + run: nix profile install nixpkgs#nix-update + + - name: Configure Git + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + - name: Get current version for comparison + id: current-version + run: | + CURRENT_VERSION=$(grep -o 'version = "[^"]*"' package.nix | head -1 | sed 's/version = "\(.*\)"/\1/') + echo "current-version=$CURRENT_VERSION" >> $GITHUB_OUTPUT + echo "Current version: $CURRENT_VERSION" + + - name: Update OpenCode with nix-update + id: update-check + run: | + echo "Running nix-update for OpenCode..." + + # Run nix-update using the configured updateScript + if nix-update opencode --use-update-script --build; then + # Check if any files were actually changed + if git diff --quiet; then + echo "No changes detected - already at latest version" + echo "has-changes=false" >> $GITHUB_OUTPUT + else + NEW_VERSION=$(grep -o 'version = "[^"]*"' package.nix | head -1 | sed 's/version = "\(.*\)"/\1/') + echo "Successfully updated to version: $NEW_VERSION" + echo "has-changes=true" >> $GITHUB_OUTPUT + echo "new-version=$NEW_VERSION" >> $GITHUB_OUTPUT + fi + else + echo "nix-update failed" + exit 1 + fi + + - name: Handle manual version input + if: github.event.inputs.version + id: manual-version + run: | + MANUAL_VERSION="${{ github.event.inputs.version }}" + CURRENT_VERSION="${{ steps.current-version.outputs.current-version }}" + + if [ "$CURRENT_VERSION" = "$MANUAL_VERSION" ]; then + echo "Already at requested version: $MANUAL_VERSION" + echo "has-changes=false" >> $GITHUB_OUTPUT + else + echo "Manual version specified: $MANUAL_VERSION" + # For manual versions, we'll run nix-update and then check if it updated to the desired version + NEW_VERSION=$(grep -o 'version = "[^"]*"' package.nix | head -1 | sed 's/version = "\(.*\)"/\1/') + if [ "$NEW_VERSION" = "$MANUAL_VERSION" ]; then + echo "Successfully updated to manual version: $MANUAL_VERSION" + else + echo "Warning: nix-update found version $NEW_VERSION, but manual version $MANUAL_VERSION was requested" + fi + fi + + - name: Create update branch and commit changes + if: steps.update-check.outputs.has-changes == 'true' + id: create-branch + run: | + NEW_VERSION="${{ steps.update-check.outputs.new-version }}" + BRANCH_NAME="update-opencode-${NEW_VERSION}-$(date +%s)" + echo "branch-name=$BRANCH_NAME" >> $GITHUB_OUTPUT + + echo "Creating branch: $BRANCH_NAME" + git checkout -b "$BRANCH_NAME" + + echo "Committing changes" + git add . + COMMIT_MSG="Update OpenCode to version $NEW_VERSION + +- Updated version and all platform-specific hashes +- Updated subpackage dependencies (tui, node_modules) +- Automated update via nix-update" + + git commit -m "$COMMIT_MSG" + + - name: Create tag on branch + if: steps.update-check.outputs.has-changes == 'true' + run: | + NEW_VERSION="${{ steps.update-check.outputs.new-version }}" + echo "Creating tag v$NEW_VERSION" + git tag -a "v$NEW_VERSION" -m "OpenCode Flake version $NEW_VERSION" + + - name: Merge branch to master + if: steps.update-check.outputs.has-changes == 'true' + id: merge-branch + run: | + BRANCH_NAME="${{ steps.create-branch.outputs.branch-name }}" + echo "Switching to master and merging $BRANCH_NAME" + + # Switch to master and ensure it's up to date + git checkout ${{ github.ref_name }} + git pull origin ${{ github.ref_name }} + + # Attempt fast-forward merge + if git merge "$BRANCH_NAME" --ff-only; then + echo "Successfully merged $BRANCH_NAME to master" + echo "merge-success=true" >> $GITHUB_OUTPUT + else + echo "Fast-forward merge failed. Master may have changed during update." + echo "merge-success=false" >> $GITHUB_OUTPUT + echo "This could happen if:" + echo "1. Another workflow updated master during this run" + echo "2. Manual commits were made to master" + echo "The update branch $BRANCH_NAME contains the changes and can be manually reviewed." + exit 1 + fi + + - name: Handle merge failure + if: failure() && steps.merge-branch.outputs.merge-success == 'false' + run: | + echo "Merge failed - the update was successful but couldn't be automatically merged." + echo "Branch ${{ steps.create-branch.outputs.branch-name }} contains the updates." + echo "Manual intervention may be required to resolve conflicts." + + - name: Push changes and tags + if: steps.update-check.outputs.has-changes == 'true' + run: | + NEW_VERSION="${{ steps.update-check.outputs.new-version }}" + echo "Pushing master and tags" + git push origin ${{ github.ref_name }} + git push origin "v$NEW_VERSION" + + - name: Create GitHub Release + if: steps.update-check.outputs.has-changes == 'true' + uses: softprops/action-gh-release@v1 + with: + tag_name: v${{ steps.update-check.outputs.new-version }} + name: OpenCode Flake ${{ steps.update-check.outputs.new-version }} + body: | + OpenCode Flake version ${{ steps.update-check.outputs.new-version }} + + This release packages [OpenCode](https://github.com/sst/opencode) v${{ steps.update-check.outputs.new-version }} as a Nix flake. + + **Automated Update**: This version was automatically updated using nix-update, ensuring all dependencies and hashes are correct. + + ## Installation + + ```bash + # Run OpenCode directly + nix run github:AodhanHayter/opencode-flake + + # Or install to your profile + nix profile install github:AodhanHayter/opencode-flake + ``` + + ## Using in a flake + + ```nix + { + inputs.opencode-flake.url = "github:AodhanHayter/opencode-flake"; + + outputs = { self, nixpkgs, opencode-flake, ... }: { + # Use in your outputs + packages.x86_64-linux.opencode = opencode-flake.packages.x86_64-linux.default; + }; + } + ``` + draft: false + prerelease: false + + - name: Cleanup update branch + if: always() && steps.create-branch.outputs.branch-name + run: | + BRANCH_NAME="${{ steps.create-branch.outputs.branch-name }}" + if [ -n "$BRANCH_NAME" ]; then + echo "Cleaning up branch: $BRANCH_NAME" + # Ensure we're on master before deleting branch + git checkout ${{ github.ref_name }} 2>/dev/null || true + # Delete the update branch + git branch -D "$BRANCH_NAME" 2>/dev/null || echo "Branch $BRANCH_NAME already deleted or doesn't exist" + fi + + - name: Summary + if: always() + run: | + if [ "${{ steps.update-check.outputs.has-changes }}" = "true" ]; then + echo "✅ Successfully updated OpenCode to version ${{ steps.update-check.outputs.new-version }}" + echo "đŸˇī¸ Created tag and GitHub release" + else + echo "â„šī¸ No updates needed - already at latest version" + fi \ No newline at end of file From b45470a2a812cff9a16f5794e874162d04b6b7d4 Mon Sep 17 00:00:00 2001 From: Aodhan Hayter Date: Tue, 2 Sep 2025 21:40:56 -0600 Subject: [PATCH 3/4] Add minimal scheduled update workflow to test triggers --- .github/workflows/scheduled-update.yml | 33 ++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/scheduled-update.yml diff --git a/.github/workflows/scheduled-update.yml b/.github/workflows/scheduled-update.yml new file mode 100644 index 0000000..dd46639 --- /dev/null +++ b/.github/workflows/scheduled-update.yml @@ -0,0 +1,33 @@ +name: Scheduled OpenCode Update + +on: + workflow_dispatch: + schedule: + - cron: '15 */6 * * *' # Run at 00:15, 06:15, 12:15, 18:15 UTC + +permissions: + contents: write + +jobs: + update: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }} + + - name: Setup Nix + uses: cachix/install-nix-action@v24 + with: + nix_path: nixpkgs=channel:nixos-unstable + extra_nix_config: | + experimental-features = nix-command flakes + + - name: Run Update + run: | + echo "Starting OpenCode update check..." + nix --version + echo "Workflow triggered by: ${{ github.event_name }}" + echo "Current time: $(date)" + # Add actual update logic here once workflow is confirmed working \ No newline at end of file From 64a22b5db726a559685a639972a19083b998f761 Mon Sep 17 00:00:00 2001 From: Aodhan Hayter Date: Tue, 2 Sep 2025 21:42:55 -0600 Subject: [PATCH 4/4] Remove test workflow files - keeping only the fixed main workflow --- .github/workflows/scheduled-update.yml | 33 --- .github/workflows/test-workflow.yml | 27 --- .github/workflows/update-opencode-fixed.yml | 231 -------------------- .github/workflows/update-opencode.yml | 61 +++--- 4 files changed, 30 insertions(+), 322 deletions(-) delete mode 100644 .github/workflows/scheduled-update.yml delete mode 100644 .github/workflows/test-workflow.yml delete mode 100644 .github/workflows/update-opencode-fixed.yml diff --git a/.github/workflows/scheduled-update.yml b/.github/workflows/scheduled-update.yml deleted file mode 100644 index dd46639..0000000 --- a/.github/workflows/scheduled-update.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Scheduled OpenCode Update - -on: - workflow_dispatch: - schedule: - - cron: '15 */6 * * *' # Run at 00:15, 06:15, 12:15, 18:15 UTC - -permissions: - contents: write - -jobs: - update: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - token: ${{ secrets.PERSONAL_ACCESS_TOKEN || github.token }} - - - name: Setup Nix - uses: cachix/install-nix-action@v24 - with: - nix_path: nixpkgs=channel:nixos-unstable - extra_nix_config: | - experimental-features = nix-command flakes - - - name: Run Update - run: | - echo "Starting OpenCode update check..." - nix --version - echo "Workflow triggered by: ${{ github.event_name }}" - echo "Current time: $(date)" - # Add actual update logic here once workflow is confirmed working \ No newline at end of file diff --git a/.github/workflows/test-workflow.yml b/.github/workflows/test-workflow.yml deleted file mode 100644 index c461b63..0000000 --- a/.github/workflows/test-workflow.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Test Workflow - -on: - push: - branches: [fix-workflow-schedule] - pull_request: - branches: [master] - workflow_dispatch: - schedule: - - cron: '*/15 * * * *' # Every 15 minutes for testing - -jobs: - test: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Test Schedule - run: | - echo "✅ Workflow is running successfully!" - echo "Trigger: ${{ github.event_name }}" - echo "Time: $(date)" - - - name: Check nix-update availability - run: | - nix --version || echo "Nix not available yet" \ No newline at end of file diff --git a/.github/workflows/update-opencode-fixed.yml b/.github/workflows/update-opencode-fixed.yml deleted file mode 100644 index 6a964a5..0000000 --- a/.github/workflows/update-opencode-fixed.yml +++ /dev/null @@ -1,231 +0,0 @@ -name: Update OpenCode (Fixed) - -# IMPORTANT: GitHub scheduled workflows requirements: -# 1. Only runs on the default branch (master/main) -# 2. Automatically disabled after 60 days of repository inactivity -# 3. Must be pushed to default branch before schedule activates -# 4. All times are in UTC -# -# To reactivate after inactivity: -# - Make any commit to the repository -# - Or manually trigger using workflow_dispatch - -on: - schedule: - # Run every 6 hours at 15 minutes past (avoids peak times) - # Times: 00:15, 06:15, 12:15, 18:15 UTC - - cron: '15 */6 * * *' - workflow_dispatch: - inputs: - version: - description: 'Specific version to update to (optional)' - required: false - type: string - push: - branches: [fix-workflow-schedule] # For testing - -permissions: - contents: write - -jobs: - update-opencode: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} - - - name: Set up Nix - uses: cachix/install-nix-action@v24 - with: - nix_path: nixpkgs=channel:nixos-unstable - extra_nix_config: | - experimental-features = nix-command flakes - - - name: Install nix-update - run: nix profile install nixpkgs#nix-update - - - name: Configure Git - run: | - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - - - name: Get current version for comparison - id: current-version - run: | - CURRENT_VERSION=$(grep -o 'version = "[^"]*"' package.nix | head -1 | sed 's/version = "\(.*\)"/\1/') - echo "current-version=$CURRENT_VERSION" >> $GITHUB_OUTPUT - echo "Current version: $CURRENT_VERSION" - - - name: Update OpenCode with nix-update - id: update-check - run: | - echo "Running nix-update for OpenCode..." - - # Run nix-update using the configured updateScript - if nix-update opencode --use-update-script --build; then - # Check if any files were actually changed - if git diff --quiet; then - echo "No changes detected - already at latest version" - echo "has-changes=false" >> $GITHUB_OUTPUT - else - NEW_VERSION=$(grep -o 'version = "[^"]*"' package.nix | head -1 | sed 's/version = "\(.*\)"/\1/') - echo "Successfully updated to version: $NEW_VERSION" - echo "has-changes=true" >> $GITHUB_OUTPUT - echo "new-version=$NEW_VERSION" >> $GITHUB_OUTPUT - fi - else - echo "nix-update failed" - exit 1 - fi - - - name: Handle manual version input - if: github.event.inputs.version - id: manual-version - run: | - MANUAL_VERSION="${{ github.event.inputs.version }}" - CURRENT_VERSION="${{ steps.current-version.outputs.current-version }}" - - if [ "$CURRENT_VERSION" = "$MANUAL_VERSION" ]; then - echo "Already at requested version: $MANUAL_VERSION" - echo "has-changes=false" >> $GITHUB_OUTPUT - else - echo "Manual version specified: $MANUAL_VERSION" - # For manual versions, we'll run nix-update and then check if it updated to the desired version - NEW_VERSION=$(grep -o 'version = "[^"]*"' package.nix | head -1 | sed 's/version = "\(.*\)"/\1/') - if [ "$NEW_VERSION" = "$MANUAL_VERSION" ]; then - echo "Successfully updated to manual version: $MANUAL_VERSION" - else - echo "Warning: nix-update found version $NEW_VERSION, but manual version $MANUAL_VERSION was requested" - fi - fi - - - name: Create update branch and commit changes - if: steps.update-check.outputs.has-changes == 'true' - id: create-branch - run: | - NEW_VERSION="${{ steps.update-check.outputs.new-version }}" - BRANCH_NAME="update-opencode-${NEW_VERSION}-$(date +%s)" - echo "branch-name=$BRANCH_NAME" >> $GITHUB_OUTPUT - - echo "Creating branch: $BRANCH_NAME" - git checkout -b "$BRANCH_NAME" - - echo "Committing changes" - git add . - COMMIT_MSG="Update OpenCode to version $NEW_VERSION - -- Updated version and all platform-specific hashes -- Updated subpackage dependencies (tui, node_modules) -- Automated update via nix-update" - - git commit -m "$COMMIT_MSG" - - - name: Create tag on branch - if: steps.update-check.outputs.has-changes == 'true' - run: | - NEW_VERSION="${{ steps.update-check.outputs.new-version }}" - echo "Creating tag v$NEW_VERSION" - git tag -a "v$NEW_VERSION" -m "OpenCode Flake version $NEW_VERSION" - - - name: Merge branch to master - if: steps.update-check.outputs.has-changes == 'true' - id: merge-branch - run: | - BRANCH_NAME="${{ steps.create-branch.outputs.branch-name }}" - echo "Switching to master and merging $BRANCH_NAME" - - # Switch to master and ensure it's up to date - git checkout ${{ github.ref_name }} - git pull origin ${{ github.ref_name }} - - # Attempt fast-forward merge - if git merge "$BRANCH_NAME" --ff-only; then - echo "Successfully merged $BRANCH_NAME to master" - echo "merge-success=true" >> $GITHUB_OUTPUT - else - echo "Fast-forward merge failed. Master may have changed during update." - echo "merge-success=false" >> $GITHUB_OUTPUT - echo "This could happen if:" - echo "1. Another workflow updated master during this run" - echo "2. Manual commits were made to master" - echo "The update branch $BRANCH_NAME contains the changes and can be manually reviewed." - exit 1 - fi - - - name: Handle merge failure - if: failure() && steps.merge-branch.outputs.merge-success == 'false' - run: | - echo "Merge failed - the update was successful but couldn't be automatically merged." - echo "Branch ${{ steps.create-branch.outputs.branch-name }} contains the updates." - echo "Manual intervention may be required to resolve conflicts." - - - name: Push changes and tags - if: steps.update-check.outputs.has-changes == 'true' - run: | - NEW_VERSION="${{ steps.update-check.outputs.new-version }}" - echo "Pushing master and tags" - git push origin ${{ github.ref_name }} - git push origin "v$NEW_VERSION" - - - name: Create GitHub Release - if: steps.update-check.outputs.has-changes == 'true' - uses: softprops/action-gh-release@v1 - with: - tag_name: v${{ steps.update-check.outputs.new-version }} - name: OpenCode Flake ${{ steps.update-check.outputs.new-version }} - body: | - OpenCode Flake version ${{ steps.update-check.outputs.new-version }} - - This release packages [OpenCode](https://github.com/sst/opencode) v${{ steps.update-check.outputs.new-version }} as a Nix flake. - - **Automated Update**: This version was automatically updated using nix-update, ensuring all dependencies and hashes are correct. - - ## Installation - - ```bash - # Run OpenCode directly - nix run github:AodhanHayter/opencode-flake - - # Or install to your profile - nix profile install github:AodhanHayter/opencode-flake - ``` - - ## Using in a flake - - ```nix - { - inputs.opencode-flake.url = "github:AodhanHayter/opencode-flake"; - - outputs = { self, nixpkgs, opencode-flake, ... }: { - # Use in your outputs - packages.x86_64-linux.opencode = opencode-flake.packages.x86_64-linux.default; - }; - } - ``` - draft: false - prerelease: false - - - name: Cleanup update branch - if: always() && steps.create-branch.outputs.branch-name - run: | - BRANCH_NAME="${{ steps.create-branch.outputs.branch-name }}" - if [ -n "$BRANCH_NAME" ]; then - echo "Cleaning up branch: $BRANCH_NAME" - # Ensure we're on master before deleting branch - git checkout ${{ github.ref_name }} 2>/dev/null || true - # Delete the update branch - git branch -D "$BRANCH_NAME" 2>/dev/null || echo "Branch $BRANCH_NAME already deleted or doesn't exist" - fi - - - name: Summary - if: always() - run: | - if [ "${{ steps.update-check.outputs.has-changes }}" = "true" ]; then - echo "✅ Successfully updated OpenCode to version ${{ steps.update-check.outputs.new-version }}" - echo "đŸˇī¸ Created tag and GitHub release" - else - echo "â„šī¸ No updates needed - already at latest version" - fi \ No newline at end of file diff --git a/.github/workflows/update-opencode.yml b/.github/workflows/update-opencode.yml index e2f1ca0..8c36acf 100644 --- a/.github/workflows/update-opencode.yml +++ b/.github/workflows/update-opencode.yml @@ -14,11 +14,11 @@ on: schedule: # Run every 6 hours at 15 minutes past (avoids peak times) # Times: 00:15, 06:15, 12:15, 18:15 UTC - - cron: '15 */6 * * *' + - cron: "15 */6 * * *" workflow_dispatch: inputs: version: - description: 'Specific version to update to (optional)' + description: "Specific version to update to (optional)" required: false type: string @@ -28,23 +28,23 @@ permissions: jobs: update-opencode: runs-on: ubuntu-latest - + steps: - name: Checkout repository uses: actions/checkout@v4 with: token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} - + - name: Set up Nix uses: cachix/install-nix-action@v24 with: nix_path: nixpkgs=channel:nixos-unstable extra_nix_config: | experimental-features = nix-command flakes - + - name: Install nix-update run: nix profile install nixpkgs#nix-update - + - name: Configure Git run: | git config user.name "github-actions[bot]" @@ -56,12 +56,12 @@ jobs: CURRENT_VERSION=$(grep -o 'version = "[^"]*"' package.nix | head -1 | sed 's/version = "\(.*\)"/\1/') echo "current-version=$CURRENT_VERSION" >> $GITHUB_OUTPUT echo "Current version: $CURRENT_VERSION" - + - name: Update OpenCode with nix-update id: update-check run: | echo "Running nix-update for OpenCode..." - + # Run nix-update using the configured updateScript if nix-update opencode --use-update-script --build; then # Check if any files were actually changed @@ -85,7 +85,7 @@ jobs: run: | MANUAL_VERSION="${{ github.event.inputs.version }}" CURRENT_VERSION="${{ steps.current-version.outputs.current-version }}" - + if [ "$CURRENT_VERSION" = "$MANUAL_VERSION" ]; then echo "Already at requested version: $MANUAL_VERSION" echo "has-changes=false" >> $GITHUB_OUTPUT @@ -107,36 +107,35 @@ jobs: NEW_VERSION="${{ steps.update-check.outputs.new-version }}" BRANCH_NAME="update-opencode-${NEW_VERSION}-$(date +%s)" echo "branch-name=$BRANCH_NAME" >> $GITHUB_OUTPUT - + echo "Creating branch: $BRANCH_NAME" git checkout -b "$BRANCH_NAME" - + echo "Committing changes" git add . git commit -m "Update OpenCode to version $NEW_VERSION + - Updated version and all platform-specific hashes + - Updated subpackage dependencies (tui, node_modules) + - Automated update via nix-update" -- Updated version and all platform-specific hashes -- Updated subpackage dependencies (tui, node_modules) -- Automated update via nix-update" - - name: Create tag on branch if: steps.update-check.outputs.has-changes == 'true' run: | NEW_VERSION="${{ steps.update-check.outputs.new-version }}" echo "Creating tag v$NEW_VERSION" git tag -a "v$NEW_VERSION" -m "OpenCode Flake version $NEW_VERSION" - + - name: Merge branch to master if: steps.update-check.outputs.has-changes == 'true' id: merge-branch run: | BRANCH_NAME="${{ steps.create-branch.outputs.branch-name }}" echo "Switching to master and merging $BRANCH_NAME" - + # Switch to master and ensure it's up to date git checkout ${{ github.ref_name }} git pull origin ${{ github.ref_name }} - + # Attempt fast-forward merge if git merge "$BRANCH_NAME" --ff-only; then echo "Successfully merged $BRANCH_NAME to master" @@ -150,14 +149,14 @@ jobs: echo "The update branch $BRANCH_NAME contains the changes and can be manually reviewed." exit 1 fi - + - name: Handle merge failure if: failure() && steps.merge-branch.outputs.merge-success == 'false' run: | echo "Merge failed - the update was successful but couldn't be automatically merged." echo "Branch ${{ steps.create-branch.outputs.branch-name }} contains the updates." echo "Manual intervention may be required to resolve conflicts." - + - name: Push changes and tags if: steps.update-check.outputs.has-changes == 'true' run: | @@ -165,7 +164,7 @@ jobs: echo "Pushing master and tags" git push origin ${{ github.ref_name }} git push origin "v$NEW_VERSION" - + - name: Create GitHub Release if: steps.update-check.outputs.has-changes == 'true' uses: softprops/action-gh-release@v1 @@ -174,27 +173,27 @@ jobs: name: OpenCode Flake ${{ steps.update-check.outputs.new-version }} body: | OpenCode Flake version ${{ steps.update-check.outputs.new-version }} - + This release packages [OpenCode](https://github.com/sst/opencode) v${{ steps.update-check.outputs.new-version }} as a Nix flake. - + **Automated Update**: This version was automatically updated using nix-update, ensuring all dependencies and hashes are correct. - + ## Installation - + ```bash # Run OpenCode directly nix run github:AodhanHayter/opencode-flake - + # Or install to your profile nix profile install github:AodhanHayter/opencode-flake ``` - + ## Using in a flake - + ```nix { inputs.opencode-flake.url = "github:AodhanHayter/opencode-flake"; - + outputs = { self, nixpkgs, opencode-flake, ... }: { # Use in your outputs packages.x86_64-linux.opencode = opencode-flake.packages.x86_64-linux.default; @@ -203,7 +202,7 @@ jobs: ``` draft: false prerelease: false - + - name: Cleanup update branch if: always() && steps.create-branch.outputs.branch-name run: | @@ -224,4 +223,4 @@ jobs: echo "đŸˇī¸ Created tag and GitHub release" else echo "â„šī¸ No updates needed - already at latest version" - fi \ No newline at end of file + fi