ci #4
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: publish | |
| on: | |
| push: | |
| branches: | |
| - dev | |
| - main | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Version to release (e.g., 1.0.0)" | |
| required: false | |
| type: string | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: write | |
| packages: write | |
| jobs: | |
| build-cli: | |
| name: Build CLI (${{ matrix.os }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Install dependencies | |
| run: bun install | |
| - name: Build | |
| run: bun run --cwd packages/opencode build --single | |
| env: | |
| OPENCODE_VERSION: ${{ inputs.version || '' }} | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: opencode-${{ matrix.os }} | |
| path: packages/opencode/dist/ | |
| release: | |
| name: Create Release | |
| needs: build-cli | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Display structure | |
| run: ls -R artifacts | |
| - name: Package artifacts | |
| run: | | |
| mkdir -p release | |
| cd artifacts | |
| for dir in */; do | |
| platform="${dir%/}" | |
| if [ -d "$dir" ]; then | |
| cd "$dir" | |
| for subdir in */; do | |
| if [ -d "$subdir" ]; then | |
| cd "$subdir" | |
| if [ -f "bin/opencode.exe" ]; then | |
| zip -j "../../../release/opencode-windows-x64.zip" bin/opencode.exe | |
| elif [ -f "bin/opencode" ]; then | |
| tar -czf "../../../release/opencode-${platform}.tar.gz" -C bin opencode | |
| fi | |
| cd .. | |
| fi | |
| done | |
| cd .. | |
| fi | |
| done | |
| - name: Generate version | |
| id: version | |
| run: echo "version=dev-$(date +'%Y%m%d%H%M%S')-${GITHUB_SHA::7}" >> $GITHUB_OUTPUT | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ steps.version.outputs.version }} | |
| name: Release ${{ steps.version.outputs.version }} | |
| draft: false | |
| prerelease: true | |
| generate_release_notes: true | |
| files: release/* | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |