diff --git a/.github/workflows/opencode-smoke.yml b/.github/workflows/opencode-smoke.yml new file mode 100644 index 0000000..271076f --- /dev/null +++ b/.github/workflows/opencode-smoke.yml @@ -0,0 +1,145 @@ +name: Opencode Smoke + +on: + workflow_dispatch: + inputs: + tag: + description: 'npm dist-tag to test' + required: true + default: next + timeout: + description: 'seconds to wait before considering opencode stable' + required: false + default: '30' + workflow_call: + inputs: + tag: + type: string + required: true + timeout: + type: number + required: false + default: 30 + +jobs: + smoke: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest] + permissions: + contents: read + steps: + - uses: actions/checkout@v4 + + - name: Resolve plugin version + id: version + run: | + VERSION=$(npm view opencode-synced@${{ inputs.tag }} version) + if [ -z "$VERSION" ]; then + echo "No version found for tag: ${{ inputs.tag }}" + exit 1 + fi + echo "version=$VERSION" >> "$GITHUB_OUTPUT" + + - name: Install opencode + env: + OPENCODE_INSTALL_DIR: ${{ runner.temp }}/opencode/bin + run: | + curl -fsSL https://opencode.ai/install | bash + echo "${OPENCODE_INSTALL_DIR}" >> "$GITHUB_PATH" + + - name: Configure clean opencode home + env: + OPENCODE_HOME: ${{ runner.temp }}/opencode-home + PLUGIN_VERSION: ${{ steps.version.outputs.version }} + run: | + export HOME="$OPENCODE_HOME" + export XDG_CONFIG_HOME="$HOME/.config" + export XDG_CACHE_HOME="$HOME/.cache" + export XDG_DATA_HOME="$HOME/.local/share" + export XDG_STATE_HOME="$HOME/.local/state" + + mkdir -p "$XDG_CONFIG_HOME/opencode" + cat > "$XDG_CONFIG_HOME/opencode/opencode.json" <> "$GITHUB_OUTPUT" + + CANDIDATE_TAG="next" + echo "Publishing candidate with tag: $CANDIDATE_TAG (requested: $TAG)" + mise run publish --tag "$CANDIDATE_TAG" + + - name: Resolve published version + id: version + run: | + VERSION=$(npm view opencode-synced@next version) + if [ -z "$VERSION" ]; then + echo "Failed to resolve version from npm tag: next" + exit 1 + fi + echo "version=$VERSION" >> "$GITHUB_OUTPUT" + + smoke: + needs: publish + uses: ./.github/workflows/opencode-smoke.yml + with: + tag: next + timeout: 20 + + promote_latest: + needs: [publish, smoke] + if: needs.publish.outputs.requested_tag == 'latest' + runs-on: ubuntu-latest + permissions: + id-token: write + contents: read + steps: + - uses: actions/checkout@v4 + + - uses: jdx/mise-action@d6e32c1796099e0f1f3ac741c220a8b7eae9e5dd + with: + install: true + cache: true + experimental: true + + - name: Promote latest dist-tag + run: | + VERSION="${{ needs.publish.outputs.version }}" + if [ -z "$VERSION" ]; then + echo "Missing published version." + exit 1 + fi + + echo "Promoting opencode-synced@$VERSION to latest" + npm dist-tag add "opencode-synced@$VERSION" latest