Skip to content

Commit 289242a

Browse files
BYKcursoragent
andauthored
feat: Configure GitHub artifact provider to filter by workflow and name (#709)
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
1 parent dad2314 commit 289242a

10 files changed

Lines changed: 978 additions & 114 deletions

File tree

.craft.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
minVersion: '2.14.0'
22
changelog:
33
policy: auto
4+
artifactProvider:
5+
name: github
6+
config:
7+
artifacts:
8+
Build & Test:
9+
- craft-binary
10+
- craft-docs
411
preReleaseCommand: >-
512
node -p "
613
const {execSync} = require('child_process');

.github/workflows/build.yml

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ jobs:
8080
- name: Upload Build Artifact
8181
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
8282
with:
83-
name: ${{ github.sha }}-build
83+
name: craft-binary
8484
path: |
8585
${{ github.workspace }}/*.tgz
8686
${{ github.workspace }}/dist/craft
@@ -114,33 +114,5 @@ jobs:
114114
- name: Upload Docs Artifact
115115
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
116116
with:
117-
name: ${{ github.sha }}-docs
117+
name: craft-docs
118118
path: ${{ github.workspace }}/gh-pages.zip
119-
120-
merge-artifacts:
121-
name: Merge Artifacts
122-
needs:
123-
- build
124-
- docs
125-
if: always() && needs.build.result == 'success' && needs.docs.result == 'success'
126-
runs-on: ubuntu-latest
127-
permissions:
128-
contents: read
129-
steps:
130-
- name: Download Build Artifacts
131-
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
132-
with:
133-
name: ${{ github.sha }}-build
134-
- name: Download Docs Artifacts
135-
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
136-
with:
137-
name: ${{ github.sha }}-docs
138-
- name: Archive Merged Artifacts
139-
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
140-
with:
141-
name: ${{ github.sha }}
142-
path: |
143-
${{ github.workspace }}/*.tgz
144-
${{ github.workspace }}/dist/craft
145-
${{ github.workspace }}/gh-pages.zip
146-
if-no-files-found: ignore

docs/src/content/docs/configuration.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,81 @@ artifactProvider:
406406
name: github # or 'gcs' or 'none'
407407
```
408408

409+
### GitHub Artifact Provider Configuration
410+
411+
By default, the GitHub artifact provider looks for artifacts named exactly as the commit SHA. You can customize this with the `artifacts` configuration option.
412+
413+
#### Pattern Syntax
414+
415+
- **Regex patterns**: Wrapped in `/` (e.g., `/^build-.*$/`)
416+
- **Exact strings**: Plain text (e.g., `build`, `release-artifacts`)
417+
418+
#### Configuration Formats
419+
420+
**1. Single artifact pattern** - searches all workflows:
421+
422+
```yaml
423+
artifactProvider:
424+
name: github
425+
config:
426+
artifacts: /^sentry-.*\.tgz$/
427+
```
428+
429+
**2. Multiple artifact patterns** - searches all workflows:
430+
431+
```yaml
432+
artifactProvider:
433+
name: github
434+
config:
435+
artifacts:
436+
- /^sentry-.*\.tgz$/
437+
- release-bundle
438+
```
439+
440+
**3. Workflow-scoped patterns** - filter by workflow name:
441+
442+
```yaml
443+
artifactProvider:
444+
name: github
445+
config:
446+
artifacts:
447+
build: release-artifacts # exact workflow → exact artifact
448+
/^build-.*$/: artifacts # workflow pattern → exact artifact
449+
ci: # exact workflow → multiple artifacts
450+
- /^output-.*$/
451+
- bundle
452+
/^release-.*$/: # workflow pattern → multiple artifacts
453+
- /^dist-.*$/
454+
- checksums
455+
```
456+
457+
#### Common Examples
458+
459+
Fetch artifacts named `craft-binary` and `craft-docs` from the "Build & Test" workflow:
460+
461+
```yaml
462+
artifactProvider:
463+
name: github
464+
config:
465+
artifacts:
466+
Build & Test:
467+
- craft-binary
468+
- craft-docs
469+
```
470+
471+
Fetch all `.tgz` files from any workflow:
472+
473+
```yaml
474+
artifactProvider:
475+
name: github
476+
config:
477+
artifacts: /\.tgz$/
478+
```
479+
480+
#### Backward Compatibility
481+
482+
When `artifacts` is not configured, the provider uses the legacy behavior where it searches for an artifact with a name matching the commit SHA exactly. This ensures existing configurations continue to work without changes.
483+
409484
## Targets
410485

411486
List release targets in your configuration:

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
},
9595
"dependencies": {
9696
"marked": "^17.0.1",
97+
"p-limit": "^6.2.0",
9798
"semver": "^7.7.3"
9899
},
99100
"pnpm": {

pnpm-lock.yaml

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)