|
4 | 4 | push: |
5 | 5 | tags: |
6 | 6 | - 'v*' |
| 7 | + branches: |
| 8 | + - develop |
7 | 9 |
|
8 | 10 | permissions: |
9 | 11 | id-token: write # Required for OIDC |
10 | | - contents: read |
| 12 | + contents: write # Required for GitHub pre-releases |
11 | 13 |
|
12 | 14 | jobs: |
13 | | - publish: |
14 | | - name: Publish to npm |
| 15 | + publish-release: |
| 16 | + name: Release (tag) |
| 17 | + if: startsWith(github.ref, 'refs/tags/v') |
15 | 18 | runs-on: ubuntu-latest |
16 | 19 |
|
17 | 20 | steps: |
|
40 | 43 | run: pnpm run test |
41 | 44 |
|
42 | 45 | - name: Publish to npm |
43 | | - run: npm publish |
| 46 | + run: npm publish --access public |
| 47 | + |
| 48 | + publish-prerelease: |
| 49 | + name: Pre-release (develop) |
| 50 | + if: github.ref == 'refs/heads/develop' |
| 51 | + runs-on: ubuntu-latest |
| 52 | + |
| 53 | + steps: |
| 54 | + - name: Checkout repository |
| 55 | + uses: actions/checkout@v4 |
| 56 | + with: |
| 57 | + fetch-depth: 0 |
| 58 | + |
| 59 | + - name: Setup pnpm |
| 60 | + uses: pnpm/action-setup@v4 |
| 61 | + with: |
| 62 | + version: 10.28.0 |
| 63 | + |
| 64 | + - name: Use Node.js 24 |
| 65 | + uses: actions/setup-node@v4 |
| 66 | + with: |
| 67 | + node-version: '24' |
| 68 | + registry-url: 'https://registry.npmjs.org' |
| 69 | + cache: 'pnpm' |
| 70 | + |
| 71 | + - name: Install dependencies |
| 72 | + run: pnpm install --frozen-lockfile |
| 73 | + |
| 74 | + - name: Configure Git |
| 75 | + run: | |
| 76 | + git config --global user.name "github-actions[bot]" |
| 77 | + git config --global user.email "github-actions[bot]@users.noreply.github.com" |
| 78 | +
|
| 79 | + - name: Generate pre-release version |
| 80 | + run: | |
| 81 | + CURRENT_VERSION=$(node -p "require('./package.json').version") |
| 82 | + SHORT_SHA=$(git rev-parse --short HEAD) |
| 83 | + TIMESTAMP=$(date +%Y%m%d%H%M%S) |
| 84 | + PRE_RELEASE_VERSION="${CURRENT_VERSION}-beta.${TIMESTAMP}.${SHORT_SHA}" |
| 85 | + echo "Pre-release version: $PRE_RELEASE_VERSION" |
| 86 | + echo "PRE_RELEASE_VERSION=$PRE_RELEASE_VERSION" >> "$GITHUB_ENV" |
| 87 | + npm version "$PRE_RELEASE_VERSION" --no-git-tag-version |
| 88 | +
|
| 89 | + - name: Build project |
| 90 | + run: pnpm run build |
| 91 | + |
| 92 | + - name: Run tests |
| 93 | + run: pnpm run test |
| 94 | + |
| 95 | + - name: Publish pre-release to npm |
| 96 | + run: npm publish --tag beta --access public |
| 97 | + |
| 98 | + - name: Create GitHub pre-release |
| 99 | + env: |
| 100 | + GH_TOKEN: ${{ github.token }} |
| 101 | + run: | |
| 102 | + gh release create "v${PRE_RELEASE_VERSION}" \ |
| 103 | + --title "Pre-release v${PRE_RELEASE_VERSION}" \ |
| 104 | + --notes "Pre-release from develop branch. |
| 105 | +
|
| 106 | + - Commit: ${{ github.sha }} |
| 107 | + - Branch: ${{ github.ref_name }} |
| 108 | +
|
| 109 | + Install with: |
| 110 | + \`\`\`bash |
| 111 | + npm install -g @hackmd/hackmd-cli@beta |
| 112 | + \`\`\`" \ |
| 113 | + --prerelease |
0 commit comments