|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + tag: |
| 10 | + description: 'Release tag (e.g. v0.0.1)' |
| 11 | + required: true |
| 12 | + |
| 13 | +permissions: |
| 14 | + contents: write # GitHub Release upload |
| 15 | + id-token: write # cosign keyless + npm provenance + SLSA attestation |
| 16 | + attestations: write # SLSA build provenance |
| 17 | + |
| 18 | +jobs: |
| 19 | + release: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - uses: actions/setup-node@v4 |
| 25 | + with: |
| 26 | + node-version: 22 |
| 27 | + registry-url: 'https://registry.npmjs.org' |
| 28 | + cache: npm |
| 29 | + |
| 30 | + - run: npm ci |
| 31 | + - run: npm run typecheck |
| 32 | + - run: npm test |
| 33 | + - run: npm run build |
| 34 | + |
| 35 | + # ---------- Model artifact tarball ---------- |
| 36 | + - name: Build model tarball |
| 37 | + run: | |
| 38 | + tar -czf promptpurify-model.tar.gz \ |
| 39 | + models/l5e/model.int8.onnx \ |
| 40 | + models/l5e/vocab.txt \ |
| 41 | + models/l5e/l5e.json \ |
| 42 | + models/l5e/SHA256SUMS |
| 43 | + sha256sum promptpurify-model.tar.gz > promptpurify-model.tar.gz.sha256 |
| 44 | +
|
| 45 | + - name: Verify model SHA256SUMS |
| 46 | + run: cd models/l5e && sha256sum -c SHA256SUMS |
| 47 | + |
| 48 | + # ---------- cosign keyless signature ---------- |
| 49 | + - uses: sigstore/cosign-installer@v3 |
| 50 | + |
| 51 | + - name: cosign-sign model tarball |
| 52 | + run: | |
| 53 | + cosign sign-blob --yes \ |
| 54 | + --bundle promptpurify-model.tar.gz.cosign.bundle \ |
| 55 | + promptpurify-model.tar.gz |
| 56 | +
|
| 57 | + # ---------- SLSA build provenance ---------- |
| 58 | + - uses: actions/attest-build-provenance@v1 |
| 59 | + with: |
| 60 | + subject-path: | |
| 61 | + promptpurify-model.tar.gz |
| 62 | + dist/**/* |
| 63 | +
|
| 64 | + # ---------- SBOM ---------- |
| 65 | + - name: Generate CycloneDX SBOM |
| 66 | + run: npx --yes @cyclonedx/cyclonedx-npm --output-file SBOM.cdx.json --output-format JSON |
| 67 | + |
| 68 | + # ---------- GitHub Release ---------- |
| 69 | + - name: Upload release artifacts |
| 70 | + uses: softprops/action-gh-release@v2 |
| 71 | + with: |
| 72 | + files: | |
| 73 | + promptpurify-model.tar.gz |
| 74 | + promptpurify-model.tar.gz.sha256 |
| 75 | + promptpurify-model.tar.gz.cosign.bundle |
| 76 | + SBOM.cdx.json |
| 77 | + generate_release_notes: true |
| 78 | + |
| 79 | + # ---------- npm publish with provenance ---------- |
| 80 | + - name: Publish to npm with provenance |
| 81 | + run: npm publish --provenance --access public |
| 82 | + env: |
| 83 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 84 | + |
| 85 | + # ---------- Hugging Face Hub mirror ---------- |
| 86 | + - uses: actions/setup-python@v5 |
| 87 | + with: |
| 88 | + python-version: '3.11' |
| 89 | + - name: Push to Securelayer7/promptpurify on HF Hub |
| 90 | + env: |
| 91 | + HF_TOKEN: ${{ secrets.HF_TOKEN }} |
| 92 | + run: | |
| 93 | + pip install --quiet huggingface_hub |
| 94 | + python - <<'PY' |
| 95 | + import os, shutil |
| 96 | + from huggingface_hub import HfApi |
| 97 | + repo = "Securelayer7/promptpurify" |
| 98 | + api = HfApi(token=os.environ["HF_TOKEN"]) |
| 99 | + api.create_repo(repo, repo_type="model", exist_ok=True) |
| 100 | + # MODEL_CARD.md becomes the HF README (has the YAML frontmatter HF needs) |
| 101 | + shutil.copy("MODEL_CARD.md", "models/l5e/README.md") |
| 102 | + api.upload_folder( |
| 103 | + repo_id=repo, |
| 104 | + folder_path="models/l5e", |
| 105 | + path_in_repo=".", |
| 106 | + commit_message=f"release {os.environ.get('GITHUB_REF_NAME', 'manual')}", |
| 107 | + allow_patterns=["model.int8.onnx", "vocab.txt", "l5e.json", "SHA256SUMS", "README.md"], |
| 108 | + ) |
| 109 | + PY |
0 commit comments