welan release #1
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: welan release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Release version without leading v" | |
| required: true | |
| type: string | |
| concurrency: | |
| group: welan-release | |
| cancel-in-progress: false | |
| permissions: | |
| contents: write | |
| issues: write | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | |
| GH_TOKEN: ${{ github.token }} | |
| jobs: | |
| release: | |
| name: sync, validate, build, release | |
| runs-on: ubuntu-24.04 | |
| defaults: | |
| run: | |
| shell: bash | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ github.token }} | |
| - name: Validate version input | |
| run: | | |
| version="${{ inputs.version }}" | |
| if [ -z "$version" ]; then | |
| echo "version input is required" | |
| exit 1 | |
| fi | |
| if [[ "$version" == v* ]]; then | |
| echo "version must not start with v; pass values like 1.2.3" | |
| exit 1 | |
| fi | |
| - name: Configure git identity | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| - name: Configure upstream remote | |
| run: | | |
| if git remote get-url upstream >/dev/null 2>&1; then | |
| git remote set-url upstream https://github.com/anomalyco/opencode.git | |
| else | |
| git remote add upstream https://github.com/anomalyco/opencode.git | |
| fi | |
| - name: Fetch branches and tags | |
| run: | | |
| git fetch origin dev:refs/remotes/origin/dev welan:refs/remotes/origin/welan --tags | |
| git fetch upstream dev:refs/remotes/upstream/dev | |
| - name: Sync dev to upstream dev | |
| run: | | |
| git checkout -B dev origin/dev | |
| if ! git merge-base --is-ancestor origin/dev upstream/dev; then | |
| echo "origin/dev cannot fast-forward to upstream/dev" | |
| echo "origin/dev: $(git rev-parse origin/dev)" | |
| echo "upstream/dev: $(git rev-parse upstream/dev)" | |
| exit 1 | |
| fi | |
| git merge --ff-only upstream/dev | |
| git push origin dev | |
| - name: Rebase welan onto dev | |
| id: rebase | |
| continue-on-error: true | |
| run: | | |
| git checkout -B welan origin/welan | |
| git rebase dev | |
| - name: Create issue for rebase conflict | |
| if: steps.rebase.outcome == 'failure' | |
| run: | | |
| conflicted_files="$(git diff --name-only --diff-filter=U || true)" | |
| upstream_dev="$(git rev-parse upstream/dev)" | |
| origin_dev="$(git rev-parse origin/dev)" | |
| origin_welan="$(git rev-parse origin/welan)" | |
| current_head="$(git rev-parse HEAD)" | |
| git rebase --abort || true | |
| cat > /tmp/welan-rebase-conflict.md <<EOF | |
| The manual welan release workflow hit a rebase conflict. | |
| - Version: v${{ inputs.version }} | |
| - Run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
| - upstream/dev: ${upstream_dev} | |
| - origin/dev: ${origin_dev} | |
| - origin/welan: ${origin_welan} | |
| - current HEAD during conflict: ${current_head} | |
| Conflicted files: | |
| \`\`\` | |
| ${conflicted_files} | |
| \`\`\` | |
| No release was created and welan was not pushed. | |
| EOF | |
| gh issue create \ | |
| --repo "${{ github.repository }}" \ | |
| --title "welan release v${{ inputs.version }} rebase conflict" \ | |
| --body-file /tmp/welan-rebase-conflict.md | |
| exit 1 | |
| - name: Setup Node | |
| uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 | |
| with: | |
| node-version: "24" | |
| - name: Setup Bun | |
| uses: ./.github/actions/setup-bun | |
| - name: Run typecheck | |
| run: bun typecheck | |
| - name: Run unit tests | |
| timeout-minutes: 20 | |
| run: GITHUB_ACTIONS=false bun turbo test | |
| env: | |
| OPENCODE_EXPERIMENTAL_DISABLE_FILEWATCHER: "false" | |
| - name: Check generated client | |
| working-directory: packages/client | |
| run: bun run check:generated | |
| - name: Run HttpApi exerciser gates | |
| working-directory: packages/opencode | |
| run: bun run test:httpapi | |
| - name: Run CLI subprocess regression test | |
| working-directory: packages/opencode | |
| run: bun test --timeout 30000 test/cli/run/run-process.test.ts | |
| - name: Build CLI binaries | |
| run: ./packages/opencode/script/build.ts | |
| env: | |
| OPENCODE_VERSION: ${{ inputs.version }} | |
| - name: Package selected release assets | |
| run: | | |
| asset_dir="/tmp/welan-release-assets" | |
| rm -rf "$asset_dir" | |
| mkdir -p "$asset_dir" | |
| test -d packages/opencode/dist/opencode-darwin-arm64/bin | |
| test -d packages/opencode/dist/opencode-linux-arm64/bin | |
| test -d packages/opencode/dist/opencode-linux-x64/bin | |
| ( | |
| cd packages/opencode/dist/opencode-darwin-arm64/bin | |
| zip -r "$asset_dir/opencode-darwin-arm64.zip" . | |
| ) | |
| ( | |
| cd packages/opencode/dist/opencode-linux-arm64/bin | |
| tar -czf "$asset_dir/opencode-linux-arm64.tar.gz" . | |
| ) | |
| ( | |
| cd packages/opencode/dist/opencode-linux-x64/bin | |
| tar -czf "$asset_dir/opencode-linux-x64.tar.gz" . | |
| ) | |
| ls -lh "$asset_dir" | |
| - name: Push rebased welan | |
| run: git push origin HEAD:welan --force-with-lease | |
| - name: Replace GitHub release | |
| run: | | |
| tag="v${{ inputs.version }}" | |
| target="$(git rev-parse HEAD)" | |
| if gh release view "$tag" --repo "${{ github.repository }}" >/dev/null 2>&1; then | |
| gh release delete "$tag" --repo "${{ github.repository }}" --yes | |
| fi | |
| if git ls-remote --exit-code --tags origin "refs/tags/$tag" >/dev/null 2>&1; then | |
| git push origin ":refs/tags/$tag" | |
| fi | |
| git tag -f "$tag" "$target" | |
| git push origin "refs/tags/$tag" | |
| gh release create "$tag" \ | |
| /tmp/welan-release-assets/opencode-darwin-arm64.zip \ | |
| /tmp/welan-release-assets/opencode-linux-arm64.tar.gz \ | |
| /tmp/welan-release-assets/opencode-linux-x64.tar.gz \ | |
| --repo "${{ github.repository }}" \ | |
| --target "$target" \ | |
| --title "$tag" \ | |
| --notes "Fork release built from welan at ${target}." |