-
Notifications
You must be signed in to change notification settings - Fork 0
167 lines (140 loc) · 5.75 KB
/
release.yml
File metadata and controls
167 lines (140 loc) · 5.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
name: Release (Changesets 🦋)
on:
workflow_dispatch:
push:
branches:
- main
env:
CI: true
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
jobs:
version:
timeout-minutes: 30
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
id-token: write
actions: write
steps:
- name: Checkout code repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_PAT }}
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'pnpm'
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Setup uv
uses: astral-sh/setup-uv@v6
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust build artifacts
uses: Swatinem/rust-cache@v2
with:
workspaces: |
rust/fetch -> rust/fetch/target
cache-on-failure: true
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache-dependency-path: go/fetch/go.sum
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
9.0.x
10.0.x
- name: Install dependencies
run: pnpm install
- name: Sync Python dependencies
run: uv sync --group dev
working-directory: python
- name: Restore .NET dependencies
run: dotnet restore SmooAI.Fetch.sln
working-directory: dotnet
- name: Typecheck
run: pnpm typecheck
- name: Lint
run: pnpm lint
- name: Test
run: pnpm test
- name: Build
run: pnpm build
- name: Format
run: pnpm format
- name: Version Update 🦋
id: changesets
uses: changesets/action@v1
with:
commit: '🦋 New version release'
title: '🦋 New version release'
publish: pnpm ci:publish
createGithubReleases: true
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
NPM_TOKEN: ${{ secrets.SMOOAI_NPM_TOKEN }}
- name: Publish smooai-fetch to PyPI
if: steps.changesets.outputs.published == 'true'
working-directory: python
env:
UV_PUBLISH_TOKEN: ${{ secrets.SMOOAI_PYPI_TOKEN }}
run: |
# Clean stale build artifacts from the earlier `pnpm build` run
# (which produced wheels at the pre-sync version) so `uv publish`
# doesn't try to upload the stale files alongside the fresh ones.
rm -rf dist/
uv run poe publish
- name: Publish smooai-fetch to crates.io
if: steps.changesets.outputs.published == 'true'
# --allow-dirty is needed because sync-versions.mjs modifies
# Cargo.toml (and rebuild updates Cargo.lock) between the
# committed state and publish. --locked would reject that mismatch.
run: cargo publish --allow-dirty --manifest-path rust/fetch/Cargo.toml
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.SMOOAI_CARGO_REGISTRY_TOKEN }}
- name: Tag and publish Go module
if: steps.changesets.outputs.published == 'true'
run: |
VERSION=$(node -p "require('./package.json').version")
TAG="go/fetch/v${VERSION}"
echo "Creating Go module tag: ${TAG}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag "${TAG}"
git push origin "${TAG}"
echo "Go module tagged and pushed: ${TAG}"
- name: Pack and publish SmooAI.Fetch to NuGet
if: steps.changesets.outputs.published == 'true'
run: |
dotnet pack SmooAI.Fetch/SmooAI.Fetch.csproj -c Release --nologo -o ./artifacts
dotnet nuget push "./artifacts/*.nupkg" \
--api-key "${NUGET_API_KEY}" \
--source "https://api.nuget.org/v3/index.json" \
--skip-duplicate
working-directory: dotnet
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
- name: Auto-Merge Changeset PR
run: |
PR_NUMBER=$(gh pr list --state open --head changeset-release/main --json number --jq '.[0].number')
if [[ -n "$PR_NUMBER" && "$PR_NUMBER" != "null" ]]; then
echo "Found Changeset PR #$PR_NUMBER, attempting to auto-merge..."
gh pr merge "$PR_NUMBER" --auto --squash
# Re-trigger the Release workflow
echo "Re-triggering the release workflow..."
gh workflow run release.yml
else
echo "No open Changeset PR found, skipping merge."
fi
env:
GH_TOKEN: ${{ secrets.GH_PAT }}