buildx-cli 1.0.9 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,254 @@
1
+ name: Auto Publish and Deploy Documentation
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ paths-ignore:
8
+ - '**.md'
9
+ - 'README.md'
10
+ workflow_dispatch:
11
+
12
+ permissions:
13
+ contents: write
14
+ packages: write
15
+ pages: write
16
+ id-token: write
17
+
18
+ # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
19
+ # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
20
+ concurrency:
21
+ group: "pages"
22
+ cancel-in-progress: false
23
+
24
+ jobs:
25
+ publish:
26
+ runs-on: ubuntu-latest
27
+ environment: production
28
+ steps:
29
+ - name: Checkout code
30
+ uses: actions/checkout@v4
31
+ with:
32
+ fetch-depth: 0
33
+ token: ${{ secrets.GITHUB_TOKEN }}
34
+
35
+ - name: Setup Node.js
36
+ uses: actions/setup-node@v4
37
+ with:
38
+ node-version: '22'
39
+ registry-url: 'https://registry.npmjs.org'
40
+ cache: 'yarn'
41
+
42
+ - name: Check if NPM_TOKEN is set
43
+ run: |
44
+ if [ -z "$NPM_TOKEN" ]; then
45
+ echo "NPM_TOKEN is not set"
46
+ exit 1
47
+ fi
48
+ echo "NPM_TOKEN is set"
49
+ echo "Token length: ${#NPM_TOKEN}"
50
+ env:
51
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
52
+
53
+ - name: Setup npm authentication
54
+ run: |
55
+ echo "Setting up npm authentication..."
56
+ npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
57
+ echo "NPM authentication configured"
58
+ echo "Testing authentication..."
59
+ npm whoami
60
+ env:
61
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
62
+
63
+ - name: Install dependencies with dev dependencies
64
+ run: yarn install
65
+
66
+ - name: Run validate
67
+ run: yarn validate
68
+
69
+ - name: Determine version bump type
70
+ id: version-bump
71
+ run: |
72
+ # Get the last commit message
73
+ COMMIT_MSG=$(git log -1 --pretty=%B)
74
+ echo "Commit message: $COMMIT_MSG"
75
+
76
+ # Check for version bump indicators in commit message
77
+ if echo "$COMMIT_MSG" | grep -q "\[major\]\|\[breaking\]"; then
78
+ echo "bump_type=major" >> $GITHUB_OUTPUT
79
+ echo "Version bump: MAJOR (from commit message)"
80
+ elif echo "$COMMIT_MSG" | grep -q "\[minor\]\|\[feature\]"; then
81
+ echo "bump_type=minor" >> $GITHUB_OUTPUT
82
+ echo "Version bump: MINOR (from commit message)"
83
+ elif echo "$COMMIT_MSG" | grep -q "\[patch\]\|\[fix\]\|\[bug\]"; then
84
+ echo "bump_type=patch" >> $GITHUB_OUTPUT
85
+ echo "Version bump: PATCH (from commit message)"
86
+ else
87
+ echo "bump_type=patch" >> $GITHUB_OUTPUT
88
+ echo "Version bump: PATCH (automatic fallback)"
89
+ fi
90
+
91
+ - name: Bump version and publish
92
+ run: |
93
+ # Configure git
94
+ git config --local user.email "action@github.com"
95
+ git config --local user.name "GitHub Action"
96
+
97
+ # Get bump type
98
+ BUMP_TYPE=${{ steps.version-bump.outputs.bump_type }}
99
+
100
+ # Show current version
101
+ CURRENT_VERSION=$(node -p "require('./package.json').version")
102
+ echo "Current version: $CURRENT_VERSION"
103
+
104
+ # Show package info
105
+ PACKAGE_NAME=$(node -p "require('./package.json').name")
106
+ echo "Package name: $PACKAGE_NAME"
107
+
108
+ # Check npm registry
109
+ echo "NPM registry: $(npm config get registry)"
110
+
111
+ # Check if logged in
112
+ echo "NPM whoami:"
113
+ npm whoami || echo "Not logged in to npm"
114
+
115
+ # Bump version using yarn (without git operations)
116
+ yarn version --$BUMP_TYPE --message "chore: bump version to $NEW_VERSION [skip ci]"
117
+
118
+ # Get new version
119
+ NEW_VERSION=$(node -p "require('./package.json').version")
120
+ echo "New version: $NEW_VERSION"
121
+
122
+ # Build project
123
+ yarn build
124
+
125
+ # Push changes
126
+ git push origin HEAD:main
127
+
128
+ # Create and push tag
129
+ git push origin "v$NEW_VERSION"
130
+
131
+ # Publish to npm using yarn with public access
132
+ echo "Publishing to npm..."
133
+ echo "Package: $PACKAGE_NAME"
134
+ echo "Version: $NEW_VERSION"
135
+
136
+ npm publish ./dist --access public
137
+
138
+ echo "✅ Published version $NEW_VERSION to npm"
139
+ env:
140
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
141
+
142
+ - name: Check if doc command is available or end workflow if not
143
+ id: should-run-docs
144
+ run: |
145
+ if ! yarn docs; then
146
+ echo "✅ Documentation command is not available, skipping documentation generation"
147
+ echo "should-run-docs=false" >> $GITHUB_OUTPUT
148
+ fi
149
+
150
+ - name: Generate documentation
151
+ if: steps.should-run-docs.outputs.should-run-docs == 'true'
152
+ run: |
153
+ echo "Generating documentation..."
154
+ yarn docs:clean
155
+ yarn docs
156
+ echo "✅ Documentation generated"
157
+
158
+ # Configure git
159
+ git config --local user.email "action@github.com"
160
+ git config --local user.name "GitHub Action"
161
+
162
+ # Check if there are changes in docs
163
+ if git diff --quiet docs/; then
164
+ echo "No documentation changes to commit"
165
+ else
166
+ # Add documentation changes
167
+ git add docs/
168
+
169
+ # Get the new version
170
+ NEW_VERSION=$(node -p "require('./package.json').version")
171
+
172
+ # Commit with [doc] tag
173
+ git commit -m "[doc] Update documentation for version $NEW_VERSION"
174
+
175
+ # Push documentation changes
176
+ git push origin HEAD:main
177
+
178
+ echo "✅ Documentation committed and pushed"
179
+ fi
180
+
181
+ - name: Update develop branch with new version
182
+ if: steps.should-run-docs.outputs.should-run-docs == 'true'
183
+ run: |
184
+ # Configure git
185
+ git config --local user.email "action@github.com"
186
+ git config --local user.name "GitHub Action"
187
+
188
+ # Get the new version that was just published
189
+ NEW_VERSION=$(node -p "require('./package.json').version")
190
+ echo "Updating develop branch with version: $NEW_VERSION"
191
+
192
+ # Fetch all branches
193
+ git fetch origin
194
+
195
+ # Checkout develop branch
196
+ git checkout develop
197
+
198
+ # Now merge the documentation changes from main
199
+ echo "Merging documentation changes from main..."
200
+
201
+ # Try to merge with strategy to handle conflicts
202
+ if git merge origin/main --no-edit -m "chore: merge docs from main [skip ci]" --strategy=recursive -X theirs; then
203
+ echo "✅ Merge successful"
204
+ else
205
+ echo "⚠️ Merge conflict detected, resolving..."
206
+
207
+ # Check if there are conflicts
208
+ if git diff --name-only --diff-filter=U | grep -q .; then
209
+ echo "Resolving conflicts by keeping main version for docs..."
210
+
211
+ # For docs conflicts, keep the main version
212
+ git checkout --theirs docs/
213
+ git add docs/
214
+
215
+ # For package.json conflicts, keep the develop version (with updated version)
216
+ git checkout --ours package.json
217
+ git add package.json
218
+
219
+ # Complete the merge
220
+ git commit -m "chore: resolve merge conflicts, keep main docs and develop version [skip ci]"
221
+ else
222
+ echo "No conflicts to resolve"
223
+ fi
224
+ fi
225
+
226
+ # Push all changes to develop
227
+ git push origin develop
228
+
229
+ echo "✅ Updated develop branch with version $NEW_VERSION and documentation changes"
230
+
231
+ - name: Setup Pages
232
+ if: steps.should-run-docs.outputs.should-run-docs == 'true'
233
+ uses: actions/configure-pages@v5
234
+
235
+ - name: Build with Jekyll
236
+ if: steps.should-run-docs.outputs.should-run-docs == 'true'
237
+ uses: actions/jekyll-build-pages@v1
238
+ with:
239
+ source: ./docs/api/html
240
+ destination: ./_site
241
+
242
+ - name: Upload artifact
243
+ if: steps.should-run-docs.outputs.should-run-docs == 'true'
244
+ uses: actions/upload-pages-artifact@v3
245
+
246
+ - name: Deploy to GitHub Pages
247
+ id: deployment
248
+ if: steps.should-run-docs.outputs.should-run-docs == 'true'
249
+ uses: actions/deploy-pages@v4
250
+
251
+ - name: Cleanup uncommitted changes
252
+ run: |
253
+ git clean -f
254
+ echo "✅ Cleanup completed"
@@ -0,0 +1,182 @@
1
+ name: Create Pull Request for Deployment
2
+ on:
3
+ push:
4
+ branches:
5
+ - develop
6
+ - staging
7
+ - feature/*
8
+ paths-ignore:
9
+ - '**.md'
10
+ - 'docs/**'
11
+ - 'README.md'
12
+
13
+ permissions:
14
+ contents: write
15
+ pull-requests: write
16
+
17
+ jobs:
18
+ create-pr:
19
+ runs-on: ubuntu-latest
20
+
21
+ steps:
22
+ - name: Checkout code
23
+ uses: actions/checkout@v4
24
+ with:
25
+ fetch-depth: 0
26
+ token: ${{ secrets.GITHUB_TOKEN }}
27
+
28
+ - name: Setup Node.js
29
+ uses: actions/setup-node@v4
30
+ with:
31
+ node-version: '22'
32
+ cache: 'yarn'
33
+
34
+ - name: Install dependencies
35
+ run: yarn install --frozen-lockfile
36
+
37
+ - name: Run validate
38
+ run: yarn validate
39
+
40
+ - name: Build project
41
+ run: yarn build
42
+
43
+ - name: Fetch main and develop
44
+ run: |
45
+ git fetch origin main
46
+ git fetch origin develop
47
+
48
+ - name: Check diff
49
+ id: diff
50
+ run: |
51
+ COUNT=$(git rev-list --right-only --count origin/main...origin/develop)
52
+ echo "commits_ahead=$COUNT"
53
+ echo "commits_ahead=$COUNT" >> "$GITHUB_OUTPUT"
54
+
55
+ - name: Get repository collaborators
56
+ id: collaborators
57
+ if: steps.diff.outputs.commits_ahead != '0'
58
+ run: |
59
+ # Get all collaborators with write/admin access
60
+ COLLABORATORS=$(gh api repos/${{ github.repository }}/collaborators --jq '.[] | select(.permissions.admin == true or .permissions.maintain == true or .permissions.push == true) | .login' | tr '\n' ',' | sed 's/,$//')
61
+ echo "collaborators=$COLLABORATORS" >> $GITHUB_OUTPUT
62
+
63
+ # Get team members using GraphQL (more efficient)
64
+ TEAM_MEMBERS=$(gh api graphql -F query='
65
+ query($org: String!) {
66
+ organization(login: $org) {
67
+ teams(first: 100) {
68
+ nodes {
69
+ members(first: 100) {
70
+ nodes {
71
+ login
72
+ }
73
+ }
74
+ }
75
+ }
76
+ }
77
+ }' -F org="${{ github.repository_owner }}" --jq '.data.organization.teams.nodes[].members.nodes[].login' 2>/dev/null | tr '\n' ',' | sed 's/,$//' || echo "")
78
+
79
+ echo "team_members=$TEAM_MEMBERS" >> $GITHUB_OUTPUT
80
+
81
+ - name: Check if PR creator is the only eligible reviewer
82
+ id: check_eligibility
83
+ if: steps.diff.outputs.commits_ahead != '0'
84
+ env:
85
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
86
+ run: |
87
+ PR_CREATOR="${{ github.actor }}"
88
+ COLLABORATORS="${{ steps.collaborators.outputs.collaborators }}"
89
+ TEAM_MEMBERS="${{ steps.collaborators.outputs.team_members }}"
90
+
91
+ # Combine all eligible reviewers
92
+ ALL_REVIEWERS=""
93
+ if [ ! -z "$COLLABORATORS" ]; then
94
+ ALL_REVIEWERS="$COLLABORATORS"
95
+ fi
96
+ if [ ! -z "$TEAM_MEMBERS" ]; then
97
+ if [ ! -z "$ALL_REVIEWERS" ]; then
98
+ ALL_REVIEWERS="$ALL_REVIEWERS,$TEAM_MEMBERS"
99
+ else
100
+ ALL_REVIEWERS="$TEAM_MEMBERS"
101
+ fi
102
+ fi
103
+
104
+ # Remove duplicates and the PR creator
105
+ UNIQUE_REVIEWERS=$(echo "$ALL_REVIEWERS" | tr ',' '\n' | grep -v "^$PR_CREATOR$" | sort -u | tr '\n' ',' | sed 's/,$//')
106
+
107
+ # Count unique reviewers (excluding PR creator)
108
+ REVIEWER_COUNT=$(echo "$UNIQUE_REVIEWERS" | tr ',' '\n' | grep -v "^$" | wc -l)
109
+
110
+ echo "reviewer_count=$REVIEWER_COUNT" >> $GITHUB_OUTPUT
111
+ echo "unique_reviewers=$UNIQUE_REVIEWERS" >> $GITHUB_OUTPUT
112
+ echo "pr_creator=$PR_CREATOR" >> $GITHUB_OUTPUT
113
+
114
+ # Check if PR creator is the only eligible reviewer
115
+ if [ "$REVIEWER_COUNT" -eq 0 ]; then
116
+ echo "is_only_reviewer=true" >> $GITHUB_OUTPUT
117
+ echo "Auto-assigning deployment PR to $PR_CREATOR (only eligible reviewer)"
118
+ else
119
+ echo "is_only_reviewer=false" >> $GITHUB_OUTPUT
120
+ echo "Deployment PR has $REVIEWER_COUNT other eligible reviewers: $UNIQUE_REVIEWERS"
121
+ fi
122
+
123
+ - name: Create deployment PR
124
+ if: steps.diff.outputs.commits_ahead != '0'
125
+ env:
126
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
127
+ run: |
128
+ set -euo pipefail
129
+
130
+ BRANCH="deploy/${{ github.ref_name }}-${{ github.sha }}"
131
+
132
+ git config --global user.name "github-actions"
133
+ git config --global user.email "github-actions@github.com"
134
+
135
+ git checkout -b "$BRANCH" refs/remotes/origin/develop
136
+ git push -u origin "$BRANCH"
137
+
138
+ # Ensure labels exist
139
+ gh label create deployment --description "Deployment PR" --color "#1d76db" --force || true
140
+ gh label create auto-generated --description "Created by GitHub Action" --color "#ededed" --force || true
141
+ gh label create auto-assigned --description "Auto-assigned to author" --color "#0366d6" --force || true
142
+
143
+ # Determine assignee and reviewers based on eligibility check
144
+ if [ "${{ steps.check_eligibility.outputs.is_only_reviewer }}" == "true" ]; then
145
+ ASSIGNEE="${{ steps.check_eligibility.outputs.pr_creator }}"
146
+ LABELS="deployment,auto-generated,auto-assigned"
147
+ REVIEWERS=""
148
+ echo "Auto-assigning deployment PR to $ASSIGNEE (only eligible reviewer)"
149
+ else
150
+ ASSIGNEE="${{ github.actor }}"
151
+ LABELS="deployment,auto-generated"
152
+ REVIEWERS="${{ steps.check_eligibility.outputs.unique_reviewers }}"
153
+ echo "Assigning deployment PR to $ASSIGNEE with reviewers: $REVIEWERS"
154
+ fi
155
+
156
+ # Create PR with or without reviewers
157
+ if [ -z "$REVIEWERS" ]; then
158
+ gh pr create \
159
+ --base main \
160
+ --head "$BRANCH" \
161
+ --title "🚀 Deploy: ${BRANCH#deploy/} → main" \
162
+ --body "Auto-generated deployment PR for **${{ github.ref_name }}**
163
+
164
+ $([ "${{ steps.check_eligibility.outputs.is_only_reviewer }}" == "true" ] && echo "🤖 Auto-assigned to $ASSIGNEE (only eligible reviewer)" || echo "👥 Assigned to $ASSIGNEE (other reviewers available: ${{ steps.check_eligibility.outputs.unique_reviewers }})")" \
165
+ --label "$LABELS" \
166
+ --assignee "$ASSIGNEE"
167
+ else
168
+ gh pr create \
169
+ --base main \
170
+ --head "$BRANCH" \
171
+ --title "🚀 Deploy: ${BRANCH#deploy/} → main" \
172
+ --body "Auto-generated deployment PR for **${{ github.ref_name }}**
173
+
174
+ $([ "${{ steps.check_eligibility.outputs.is_only_reviewer }}" == "true" ] && echo "🤖 Auto-assigned to $ASSIGNEE (only eligible reviewer)" || echo "👥 Assigned to $ASSIGNEE with reviewers: $REVIEWERS")" \
175
+ --label "$LABELS" \
176
+ --assignee "$ASSIGNEE" \
177
+ --reviewer "$REVIEWERS"
178
+ fi
179
+
180
+ - name: No diff – skip PR
181
+ if: steps.diff.outputs.commits_ahead == '0'
182
+ run: echo "develop is identical to main – no deployment PR needed."
package/.prettierrc ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "semi": true,
3
+ "trailingComma": "es5",
4
+ "singleQuote": true,
5
+ "printWidth": 80,
6
+ "tabWidth": 4,
7
+ "useTabs": true
8
+ }