|
1 | | -name: Release CI |
| 1 | +name: Release |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | 5 | branches: |
6 | 6 | - main |
7 | 7 |
|
8 | | -permissions: |
9 | | - contents: write |
10 | | - pull-requests: write |
| 8 | +env: |
| 9 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN_PUBLIC }} |
| 10 | + FORCE_COLOR: '3' |
11 | 11 |
|
12 | 12 | jobs: |
13 | | - ci: |
14 | | - name: CI Init |
15 | | - runs-on: [self-hosted, Linux] |
16 | | - outputs: |
17 | | - action: ${{ steps.init.outputs.action }} |
| 13 | + release: |
| 14 | + name: Create Release PR |
| 15 | + runs-on: ubuntu-latest |
| 16 | + if: "!contains(github.event.head_commit.message, '🚀 release:')" |
| 17 | + timeout-minutes: 10 |
18 | 18 | steps: |
19 | | - - id: init |
20 | | - uses: localazy/release/init@v2 |
21 | | - |
22 | | - prepare: |
23 | | - name: Prepare Release PR |
24 | | - needs: ci |
25 | | - if: needs.ci.outputs.action == 'prepare' |
26 | | - runs-on: [self-hosted, Linux] |
27 | | - steps: |
28 | | - - uses: localazy/release/prepare@v2 |
| 19 | + - name: Checkout repository |
| 20 | + uses: actions/checkout@v6 |
| 21 | + with: |
| 22 | + fetch-depth: 0 |
| 23 | + |
| 24 | + - name: Generate token |
| 25 | + id: auth |
| 26 | + uses: actions/create-github-app-token@v3 |
29 | 27 | with: |
30 | | - node-version-file: .nvmrc |
31 | 28 | app-id: ${{ secrets.AUTH_APP_ID }} |
32 | | - app-key: ${{ secrets.AUTH_APP_KEY }} |
33 | | - badges: true |
34 | | - badges-size: dist/browser/localazy-api-client.umd.min.js |
| 29 | + private-key: ${{ secrets.AUTH_APP_KEY }} |
| 30 | + |
| 31 | + - name: Clean pnpm setup cache |
| 32 | + run: rm -rf ~/setup-pnpm |
| 33 | + |
| 34 | + - name: Setup pnpm |
| 35 | + uses: pnpm/action-setup@v5 |
| 36 | + |
| 37 | + - name: Setup Node |
| 38 | + uses: actions/setup-node@v6 |
| 39 | + with: |
| 40 | + node-version-file: .nvmrc |
| 41 | + registry-url: https://registry.npmjs.org |
| 42 | + |
| 43 | + - name: Install dependencies |
| 44 | + run: pnpm install --frozen-lockfile |
| 45 | + |
| 46 | + - name: Run release script |
| 47 | + run: pnpx @localazy/workflow-scripts create-release-pr . |
| 48 | + env: |
| 49 | + GITHUB_TOKEN: ${{ steps.auth.outputs.token }} |
35 | 50 |
|
36 | 51 | publish: |
37 | | - name: Publish Release |
38 | | - needs: ci |
39 | | - if: needs.ci.outputs.action == 'publish' |
40 | | - runs-on: [self-hosted, Linux] |
| 52 | + name: Publish to npm |
| 53 | + runs-on: ubuntu-latest |
| 54 | + if: "contains(github.event.head_commit.message, '🚀 release:')" |
| 55 | + timeout-minutes: 10 |
| 56 | + permissions: |
| 57 | + contents: write |
41 | 58 | steps: |
42 | | - - uses: localazy/release/publish@v2 |
| 59 | + - name: Generate token |
| 60 | + id: auth |
| 61 | + uses: actions/create-github-app-token@v3 |
43 | 62 | with: |
44 | | - node-version-file: .nvmrc |
45 | 63 | app-id: ${{ secrets.AUTH_APP_ID }} |
46 | | - app-key: ${{ secrets.AUTH_APP_KEY }} |
47 | | - npm-publish: public |
48 | | - npm-token: ${{ secrets.NPM_AUTH_TOKEN_PUBLIC }} |
| 64 | + private-key: ${{ secrets.AUTH_APP_KEY }} |
| 65 | + |
| 66 | + - name: Checkout repository |
| 67 | + uses: actions/checkout@v6 |
| 68 | + with: |
| 69 | + fetch-depth: 0 |
| 70 | + |
| 71 | + - name: Clean pnpm setup cache |
| 72 | + run: rm -rf ~/setup-pnpm |
| 73 | + |
| 74 | + - name: Setup pnpm |
| 75 | + uses: pnpm/action-setup@v5 |
| 76 | + |
| 77 | + - name: Setup Node |
| 78 | + uses: actions/setup-node@v6 |
| 79 | + with: |
| 80 | + node-version-file: .nvmrc |
| 81 | + registry-url: https://registry.npmjs.org |
| 82 | + |
| 83 | + - name: Install dependencies |
| 84 | + run: pnpm install --frozen-lockfile |
| 85 | + |
| 86 | + - name: Build |
| 87 | + run: pnpm run build |
| 88 | + |
| 89 | + - name: Determine npm tag |
| 90 | + id: npm-tag |
| 91 | + run: | |
| 92 | + VERSION=$(node -p "require('./package.json').version") |
| 93 | + if echo "$VERSION" | grep -q '-'; then |
| 94 | + echo "tag=${VERSION#*-}" | sed 's/\..*//' >> "$GITHUB_OUTPUT" |
| 95 | + else |
| 96 | + echo "tag=latest" >> "$GITHUB_OUTPUT" |
| 97 | + fi |
| 98 | +
|
| 99 | + - name: Publish to npm |
| 100 | + run: pnpm publish --no-git-checks --tag ${{ steps.npm-tag.outputs.tag }} --access public |
| 101 | + |
| 102 | + - name: Create and push git tag |
| 103 | + id: git-tag |
| 104 | + run: | |
| 105 | + NAME=$(node -p "require('./package.json').name") |
| 106 | + VERSION=$(node -p "require('./package.json').version") |
| 107 | + TAG="${NAME}@${VERSION}" |
| 108 | + git tag "${TAG}" |
| 109 | + git push origin "${TAG}" |
| 110 | + echo "tag=${TAG}" >> "$GITHUB_OUTPUT" |
| 111 | + echo "version=${VERSION}" >> "$GITHUB_OUTPUT" |
| 112 | +
|
| 113 | + - name: Create GitHub Release |
| 114 | + run: pnpx @localazy/workflow-scripts create-github-release "${{ steps.git-tag.outputs.version }}" |
| 115 | + env: |
| 116 | + GITHUB_TOKEN: ${{ steps.auth.outputs.token }} |
0 commit comments