publish.yml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. name: publish
  2. run-name: "${{ format('release {0}', inputs.bump) }}"
  3. on:
  4. workflow_dispatch:
  5. inputs:
  6. bump:
  7. description: "Bump major, minor, or patch"
  8. required: true
  9. type: choice
  10. options:
  11. - major
  12. - minor
  13. - patch
  14. version:
  15. description: "Override version (optional)"
  16. required: false
  17. type: string
  18. concurrency: ${{ github.workflow }}-${{ github.ref }}
  19. permissions:
  20. contents: write
  21. packages: write
  22. jobs:
  23. publish:
  24. runs-on: blacksmith-4vcpu-ubuntu-2404
  25. if: github.repository == 'sst/opencode'
  26. steps:
  27. - uses: actions/checkout@v3
  28. with:
  29. fetch-depth: 0
  30. - run: git fetch --force --tags
  31. - uses: actions/setup-go@v5
  32. with:
  33. go-version: ">=1.24.0"
  34. cache: true
  35. cache-dependency-path: go.sum
  36. - uses: ./.github/actions/setup-bun
  37. - name: Install makepkg
  38. run: |
  39. sudo apt-get update
  40. sudo apt-get install -y pacman-package-manager
  41. - name: Setup SSH for AUR
  42. run: |
  43. mkdir -p ~/.ssh
  44. echo "${{ secrets.AUR_KEY }}" > ~/.ssh/id_rsa
  45. chmod 600 ~/.ssh/id_rsa
  46. git config --global user.email "[email protected]"
  47. git config --global user.name "opencode"
  48. ssh-keyscan -H aur.archlinux.org >> ~/.ssh/known_hosts || true
  49. - name: Install OpenCode
  50. run: curl -fsSL https://opencode.ai/install | bash
  51. - name: Setup npm auth
  52. run: |
  53. echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
  54. - name: Login to GitHub Container Registry
  55. uses: docker/login-action@v3
  56. with:
  57. registry: ghcr.io
  58. username: ${{ github.repository_owner }}
  59. password: ${{ secrets.GITHUB_TOKEN }}
  60. - name: Publish
  61. run: |
  62. ./script/publish.ts
  63. env:
  64. OPENCODE_BUMP: ${{ inputs.bump }}
  65. OPENCODE_VERSION: ${{ inputs.version }}
  66. OPENCODE_CHANNEL: latest
  67. NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}
  68. GITHUB_TOKEN: ${{ secrets.SST_GITHUB_TOKEN }}
  69. AUR_KEY: ${{ secrets.AUR_KEY }}
  70. OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
  71. publish-tauri:
  72. strategy:
  73. matrix:
  74. settings:
  75. - host: macos-latest
  76. target: x86_64-apple-darwin
  77. - host: macos-latest
  78. target: aarch64-apple-darwin
  79. - host: windows-latest
  80. target: x86_64-pc-windows-msvc
  81. - host: ubuntu-24.04
  82. target: x86_64-unknown-linux-gnu
  83. runs-on: ${{ matrix.settings.host }}
  84. steps:
  85. - uses: actions/checkout@v3
  86. with:
  87. fetch-depth: 0
  88. - run: git fetch --force --tags
  89. - uses: ./.github/actions/setup-bun
  90. - name: install dependencies (ubuntu only)
  91. if: startsWith(matrix.settings.host, 'ubuntu')
  92. run: |
  93. sudo apt-get update
  94. sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
  95. - name: install Rust stable
  96. uses: dtolnay/rust-toolchain@stable
  97. with:
  98. targets: ${{ matrix.settings.target }}
  99. - uses: Swatinem/rust-cache@v2
  100. with:
  101. workspaces: packages/tauri/src-tauri
  102. shared-key: ${{ matrix.settings.target }}
  103. - name: Prepare
  104. run: |
  105. cd packages/tauri
  106. bun ./scripts/prepare.ts
  107. env:
  108. OPENCODE_BUMP: ${{ inputs.bump }}
  109. OPENCODE_VERSION: ${{ inputs.version }}
  110. OPENCODE_CHANNEL: latest
  111. NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}
  112. GITHUB_TOKEN: ${{ secrets.SST_GITHUB_TOKEN }}
  113. AUR_KEY: ${{ secrets.AUR_KEY }}
  114. OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
  115. RUST_TARGET: ${{ matrix.settings.target }}
  116. GH_TOKEN: ${{ github.token }}
  117. # Fixes AppImage build issues, can be removed when https://github.com/tauri-apps/tauri/pull/12491 is released
  118. - run: cargo install tauri-cli --git https://github.com/tauri-apps/tauri --branch feat/truly-portable-appimage
  119. if: startsWith(matrix.settings.host, 'ubuntu')
  120. - name: Build and upload artifacts
  121. uses: tauri-apps/tauri-action@390cbe447412ced1303d35abe75287949e43437a
  122. env:
  123. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  124. TAURI_BUNDLER_NEW_APPIMAGE_FORMAT: true
  125. TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
  126. with:
  127. projectPath: packages/tauri
  128. uploadWorkflowArtifacts: true
  129. tauriScript: ${{ (startsWith(matrix.settings.host, 'ubuntu') && 'cargo tauri') || '' }}
  130. args: --target ${{ matrix.settings.target }}
  131. updaterJsonPreferNsis: true
  132. releaseDraft: true
  133. tagName: ${{ inputs.version }}
  134. releaseName: ${{ inputs.version }}