|
1 | 1 | name: Release |
2 | 2 |
|
3 | | -# MANUAL RELEASE ONLY - prevents accidental version bumps |
4 | | -# To release: Actions → Release → Run workflow → Enter version |
| 3 | +# Automatic releases on push to master based on Conventional Commits |
| 4 | +# - feat: commits trigger minor version bump |
| 5 | +# - fix: commits trigger patch version bump |
| 6 | +# - feat!: or BREAKING CHANGE: trigger major version bump |
| 7 | +# - docs:, chore:, ci:, test: commits don't trigger releases |
5 | 8 |
|
6 | 9 | on: |
| 10 | + push: |
| 11 | + branches: |
| 12 | + - master |
7 | 13 | workflow_dispatch: |
8 | 14 | inputs: |
9 | | - version: |
10 | | - description: 'Release version (e.g., 0.1.1, 0.2.0, 1.0.0)' |
11 | | - required: true |
12 | | - type: string |
13 | 15 | dry_run: |
14 | | - description: 'Dry run (no publish)' |
| 16 | + description: 'Dry run (analyze but do not publish)' |
15 | 17 | required: false |
16 | 18 | type: boolean |
17 | 19 | default: false |
18 | 20 |
|
19 | 21 | jobs: |
20 | 22 | release: |
21 | | - name: Publish to npm |
| 23 | + name: Semantic Release |
22 | 24 | runs-on: ubuntu-latest |
| 25 | + # Only run if CI passes (this job depends on CI implicitly via branch protection) |
23 | 26 | permissions: |
24 | 27 | contents: write |
| 28 | + issues: write |
| 29 | + pull-requests: write |
25 | 30 | id-token: write |
| 31 | + |
26 | 32 | steps: |
27 | | - - uses: actions/checkout@v4 |
| 33 | + - name: Checkout |
| 34 | + uses: actions/checkout@v4 |
28 | 35 | with: |
29 | 36 | fetch-depth: 0 |
| 37 | + persist-credentials: false |
30 | 38 |
|
31 | | - - name: Validate version format |
32 | | - run: | |
33 | | - if [[ ! "${{ inputs.version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$ ]]; then |
34 | | - echo "Error: Invalid version format. Use semver (e.g., 0.1.1, 0.2.0-beta.1)" |
35 | | - exit 1 |
36 | | - fi |
37 | | -
|
38 | | - - name: Set up Node.js |
| 39 | + - name: Setup Node.js |
39 | 40 | uses: actions/setup-node@v4 |
40 | 41 | with: |
41 | 42 | node-version: '20' |
42 | 43 | registry-url: 'https://registry.npmjs.org' |
43 | 44 |
|
44 | | - - name: Install PNPM |
45 | | - uses: pnpm/action-setup@v2 |
| 45 | + - name: Setup pnpm |
| 46 | + uses: pnpm/action-setup@v4 |
46 | 47 | with: |
47 | | - version: 9 |
| 48 | + version: 10 |
48 | 49 |
|
49 | 50 | - name: Install dependencies |
50 | 51 | run: pnpm install |
51 | 52 |
|
52 | 53 | - name: Build |
53 | | - run: pnpm run build |
| 54 | + run: pnpm build |
54 | 55 |
|
55 | 56 | - name: Test |
56 | | - run: pnpm run test |
| 57 | + run: pnpm test |
57 | 58 |
|
58 | | - - name: Update version in package.json |
59 | | - run: | |
60 | | - npm version ${{ inputs.version }} --no-git-tag-version |
61 | | - echo "Updated to version ${{ inputs.version }}" |
62 | | -
|
63 | | - - name: Publish to npm |
64 | | - if: ${{ !inputs.dry_run }} |
| 59 | + - name: Semantic Release (Dry Run) |
| 60 | + if: ${{ github.event.inputs.dry_run == 'true' }} |
65 | 61 | env: |
66 | | - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
67 | | - run: npm publish --access public |
68 | | - |
69 | | - - name: Dry run - would publish |
70 | | - if: ${{ inputs.dry_run }} |
71 | | - run: | |
72 | | - echo "DRY RUN - Would publish version ${{ inputs.version }}" |
73 | | - npm pack --dry-run |
74 | | -
|
75 | | - - name: Create git tag |
76 | | - if: ${{ !inputs.dry_run }} |
77 | | - run: | |
78 | | - git config user.name "github-actions[bot]" |
79 | | - git config user.email "github-actions[bot]@users.noreply.github.com" |
80 | | - git add package.json |
81 | | - git commit -m "chore(release): ${{ inputs.version }}" |
82 | | - git tag -a "v${{ inputs.version }}" -m "Release v${{ inputs.version }}" |
83 | | - git push origin HEAD:master --tags |
| 62 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 63 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 64 | + run: npx semantic-release --dry-run |
84 | 65 |
|
85 | | - - name: Create GitHub Release |
86 | | - if: ${{ !inputs.dry_run }} |
87 | | - uses: softprops/action-gh-release@v1 |
88 | | - with: |
89 | | - tag_name: "v${{ inputs.version }}" |
90 | | - name: "@framers/agentos v${{ inputs.version }}" |
91 | | - body: | |
92 | | - ## @framers/agentos v${{ inputs.version }} |
93 | | - |
94 | | - Install: |
95 | | - ```bash |
96 | | - npm install @framers/agentos@${{ inputs.version }} |
97 | | - ``` |
98 | | - |
99 | | - [View on npm](https://www.npmjs.com/package/@framers/agentos/v/${{ inputs.version }}) |
100 | | - draft: false |
101 | | - prerelease: ${{ contains(inputs.version, '-') }} |
| 66 | + - name: Semantic Release |
| 67 | + if: ${{ github.event.inputs.dry_run != 'true' }} |
102 | 68 | env: |
103 | 69 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 70 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 71 | + run: npx semantic-release |
0 commit comments