|
| 1 | +name: publish |
| 2 | +run-name: "${{ format('release {0}', inputs.bump) }}" |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - dev |
| 8 | + - snapshot-* |
| 9 | + workflow_dispatch: |
| 10 | + inputs: |
| 11 | + bump: |
| 12 | + description: "Bump major, minor, or patch" |
| 13 | + required: false |
| 14 | + type: choice |
| 15 | + options: |
| 16 | + - major |
| 17 | + - minor |
| 18 | + - patch |
| 19 | + version: |
| 20 | + description: "Override version (optional)" |
| 21 | + required: false |
| 22 | + type: string |
| 23 | + |
| 24 | +concurrency: ${{ github.workflow }}-${{ github.ref }} |
| 25 | + |
| 26 | +permissions: |
| 27 | + id-token: write |
| 28 | + contents: write |
| 29 | + packages: write |
| 30 | + |
| 31 | +jobs: |
| 32 | + publish: |
| 33 | + runs-on: blacksmith-4vcpu-ubuntu-2404 |
| 34 | + if: github.repository == 'sst/opencode' && github.ref == 'refs/heads/dev' |
| 35 | + steps: |
| 36 | + - uses: actions/checkout@v3 |
| 37 | + with: |
| 38 | + fetch-depth: 0 |
| 39 | + |
| 40 | + - run: git fetch --force --tags |
| 41 | + |
| 42 | + - uses: ./.github/actions/setup-bun |
| 43 | + |
| 44 | + - name: Setup SSH for AUR |
| 45 | + if: inputs.bump || inputs.version |
| 46 | + run: | |
| 47 | + sudo apt-get update |
| 48 | + sudo apt-get install -y pacman-package-manager |
| 49 | + mkdir -p ~/.ssh |
| 50 | + echo "${{ secrets.AUR_KEY }}" > ~/.ssh/id_rsa |
| 51 | + chmod 600 ~/.ssh/id_rsa |
| 52 | + |
| 53 | + git config --global user.name "opencode" |
| 54 | + ssh-keyscan -H aur.archlinux.org >> ~/.ssh/known_hosts || true |
| 55 | +
|
| 56 | + - name: Install OpenCode |
| 57 | + if: inputs.bump || inputs.version |
| 58 | + |
| 59 | + |
| 60 | + - name: Login to GitHub Container Registry |
| 61 | + uses: docker/login-action@v3 |
| 62 | + with: |
| 63 | + registry: ghcr.io |
| 64 | + username: ${{ github.repository_owner }} |
| 65 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 66 | + |
| 67 | + - uses: actions/setup-node@v4 |
| 68 | + with: |
| 69 | + node-version: "24" |
| 70 | + registry-url: "https://registry.npmjs.org" |
| 71 | + |
| 72 | + - name: Publish |
| 73 | + id: publish |
| 74 | + run: ./script/publish.ts |
| 75 | + env: |
| 76 | + OPENCODE_BUMP: ${{ inputs.bump }} |
| 77 | + OPENCODE_VERSION: ${{ inputs.version }} |
| 78 | + OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }} |
| 79 | + AUR_KEY: ${{ secrets.AUR_KEY }} |
| 80 | + GITHUB_TOKEN: ${{ secrets.SST_GITHUB_TOKEN }} |
| 81 | + NPM_CONFIG_PROVENANCE: false |
| 82 | + outputs: |
| 83 | + releaseId: ${{ steps.publish.outputs.releaseId }} |
| 84 | + tagName: ${{ steps.publish.outputs.tagName }} |
| 85 | + |
| 86 | + publish-tauri: |
| 87 | + needs: publish |
| 88 | + continue-on-error: true |
| 89 | + strategy: |
| 90 | + fail-fast: false |
| 91 | + matrix: |
| 92 | + settings: |
| 93 | + - host: macos-latest |
| 94 | + target: x86_64-apple-darwin |
| 95 | + - host: macos-latest |
| 96 | + target: aarch64-apple-darwin |
| 97 | + - host: blacksmith-4vcpu-windows-2025 |
| 98 | + target: x86_64-pc-windows-msvc |
| 99 | + - host: blacksmith-4vcpu-ubuntu-2404 |
| 100 | + target: x86_64-unknown-linux-gnu |
| 101 | + runs-on: ${{ matrix.settings.host }} |
| 102 | + steps: |
| 103 | + - uses: actions/checkout@v3 |
| 104 | + with: |
| 105 | + fetch-depth: 0 |
| 106 | + |
| 107 | + - uses: apple-actions/import-codesign-certs@v2 |
| 108 | + if: ${{ runner.os == 'macOS' }} |
| 109 | + with: |
| 110 | + keychain: build |
| 111 | + p12-file-base64: ${{ secrets.APPLE_CERTIFICATE }} |
| 112 | + p12-password: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }} |
| 113 | + |
| 114 | + - name: Verify Certificate |
| 115 | + if: ${{ runner.os == 'macOS' }} |
| 116 | + run: | |
| 117 | + CERT_INFO=$(security find-identity -v -p codesigning build.keychain | grep "Developer ID Application") |
| 118 | + CERT_ID=$(echo "$CERT_INFO" | awk -F'"' '{print $2}') |
| 119 | + echo "CERT_ID=$CERT_ID" >> $GITHUB_ENV |
| 120 | + echo "Certificate imported." |
| 121 | +
|
| 122 | + - name: Setup Apple API Key |
| 123 | + if: ${{ runner.os == 'macOS' }} |
| 124 | + run: | |
| 125 | + echo "${{ secrets.APPLE_API_KEY_PATH }}" > $RUNNER_TEMP/apple-api-key.p8 |
| 126 | +
|
| 127 | + - run: git fetch --force --tags |
| 128 | + |
| 129 | + - uses: ./.github/actions/setup-bun |
| 130 | + |
| 131 | + - name: install dependencies (ubuntu only) |
| 132 | + if: contains(matrix.settings.host, 'ubuntu') |
| 133 | + run: | |
| 134 | + sudo apt-get update |
| 135 | + sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf |
| 136 | +
|
| 137 | + - name: install Rust stable |
| 138 | + uses: dtolnay/rust-toolchain@stable |
| 139 | + with: |
| 140 | + targets: ${{ matrix.settings.target }} |
| 141 | + |
| 142 | + - uses: Swatinem/rust-cache@v2 |
| 143 | + with: |
| 144 | + workspaces: packages/tauri/src-tauri |
| 145 | + shared-key: ${{ matrix.settings.target }} |
| 146 | + |
| 147 | + - name: Prepare |
| 148 | + run: | |
| 149 | + cd packages/tauri |
| 150 | + bun ./scripts/prepare.ts |
| 151 | + env: |
| 152 | + OPENCODE_BUMP: ${{ inputs.bump }} |
| 153 | + OPENCODE_VERSION: ${{ inputs.version }} |
| 154 | + OPENCODE_CHANNEL: latest |
| 155 | + NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 156 | + GITHUB_TOKEN: ${{ secrets.SST_GITHUB_TOKEN }} |
| 157 | + AUR_KEY: ${{ secrets.AUR_KEY }} |
| 158 | + OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }} |
| 159 | + RUST_TARGET: ${{ matrix.settings.target }} |
| 160 | + GH_TOKEN: ${{ github.token }} |
| 161 | + |
| 162 | + # Fixes AppImage build issues, can be removed when https://github.com/tauri-apps/tauri/pull/12491 is released |
| 163 | + - run: cargo install tauri-cli --git https://github.com/tauri-apps/tauri --branch feat/truly-portable-appimage |
| 164 | + if: contains(matrix.settings.host, 'ubuntu') |
| 165 | + |
| 166 | + - name: Build and upload artifacts |
| 167 | + uses: tauri-apps/tauri-action@390cbe447412ced1303d35abe75287949e43437a |
| 168 | + env: |
| 169 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 170 | + TAURI_BUNDLER_NEW_APPIMAGE_FORMAT: true |
| 171 | + TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} |
| 172 | + TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} |
| 173 | + APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }} |
| 174 | + APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }} |
| 175 | + APPLE_SIGNING_IDENTITY: ${{ env.CERT_ID }} |
| 176 | + APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }} |
| 177 | + APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }} |
| 178 | + APPLE_API_KEY_PATH: ${{ runner.temp }}/apple-api-key.p8 |
| 179 | + with: |
| 180 | + projectPath: packages/tauri |
| 181 | + uploadWorkflowArtifacts: true |
| 182 | + tauriScript: ${{ (contains(matrix.settings.host, 'ubuntu') && 'cargo tauri') || '' }} |
| 183 | + args: --target ${{ matrix.settings.target }} |
| 184 | + updaterJsonPreferNsis: true |
| 185 | + releaseId: ${{ needs.publish.outputs.releaseId }} |
| 186 | + tagName: ${{ needs.publish.outputs.tagName }} |
| 187 | + assetName: opencode-desktop-[platform]-[arch][ext] |