|
| 1 | +name: Auto Release & Publish |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + id-token: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + publish-core: |
| 14 | + name: Publish qrlayout-core |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - name: Checkout |
| 18 | + uses: actions/checkout@v4 |
| 19 | + with: |
| 20 | + fetch-depth: 0 |
| 21 | + |
| 22 | + - name: Setup Node.js |
| 23 | + uses: actions/setup-node@v4 |
| 24 | + with: |
| 25 | + node-version: '20' |
| 26 | + registry-url: 'https://registry.npmjs.org' |
| 27 | + |
| 28 | + - name: Get core version |
| 29 | + id: core_pkg |
| 30 | + run: | |
| 31 | + VERSION=$(node -p "require('./packages/core/package.json').version") |
| 32 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 33 | + echo "Core version: $VERSION" |
| 34 | +
|
| 35 | + - name: Check if core tag exists |
| 36 | + id: core_tag |
| 37 | + run: | |
| 38 | + git fetch --tags |
| 39 | + if git rev-parse "qrlayout-core@${{ steps.core_pkg.outputs.version }}" >/dev/null 2>&1; then |
| 40 | + echo "exists=true" >> $GITHUB_OUTPUT |
| 41 | + echo "qrlayout-core@${{ steps.core_pkg.outputs.version }} already published — skipping" |
| 42 | + else |
| 43 | + echo "exists=false" >> $GITHUB_OUTPUT |
| 44 | + echo "qrlayout-core@${{ steps.core_pkg.outputs.version }} not found — will publish" |
| 45 | + fi |
| 46 | +
|
| 47 | + - name: Install dependencies |
| 48 | + if: steps.core_tag.outputs.exists == 'false' |
| 49 | + run: npm ci |
| 50 | + |
| 51 | + - name: Build core |
| 52 | + if: steps.core_tag.outputs.exists == 'false' |
| 53 | + run: npm run build:core |
| 54 | + |
| 55 | + - name: Publish qrlayout-core |
| 56 | + if: steps.core_tag.outputs.exists == 'false' |
| 57 | + run: | |
| 58 | + cd packages/core |
| 59 | + echo "Publishing qrlayout-core@${{ steps.core_pkg.outputs.version }}..." |
| 60 | + npm publish --access public |
| 61 | + echo "Done!" |
| 62 | + env: |
| 63 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 64 | + |
| 65 | + - name: Create GitHub Release for core |
| 66 | + if: steps.core_tag.outputs.exists == 'false' |
| 67 | + uses: softprops/action-gh-release@v2 |
| 68 | + with: |
| 69 | + tag_name: qrlayout-core@${{ steps.core_pkg.outputs.version }} |
| 70 | + name: qrlayout-core v${{ steps.core_pkg.outputs.version }} |
| 71 | + body: | |
| 72 | + ## qrlayout-core v${{ steps.core_pkg.outputs.version }} |
| 73 | +
|
| 74 | + ### Install |
| 75 | + ```bash |
| 76 | + npm i qrlayout-core |
| 77 | + ``` |
| 78 | +
|
| 79 | + See [CHANGELOG](https://github.com/shashi089/qr-code-layout-generate-tool/blob/main/packages/core/CHANGELOG.md) for details. |
| 80 | + draft: false |
| 81 | + prerelease: false |
| 82 | + env: |
| 83 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 84 | + |
| 85 | + publish-ui: |
| 86 | + name: Publish qrlayout-ui |
| 87 | + runs-on: ubuntu-latest |
| 88 | + needs: publish-core |
| 89 | + steps: |
| 90 | + - name: Checkout |
| 91 | + uses: actions/checkout@v4 |
| 92 | + with: |
| 93 | + fetch-depth: 0 |
| 94 | + |
| 95 | + - name: Setup Node.js |
| 96 | + uses: actions/setup-node@v4 |
| 97 | + with: |
| 98 | + node-version: '20' |
| 99 | + registry-url: 'https://registry.npmjs.org' |
| 100 | + |
| 101 | + - name: Get ui version |
| 102 | + id: ui_pkg |
| 103 | + run: | |
| 104 | + VERSION=$(node -p "require('./packages/ui/package.json').version") |
| 105 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 106 | + echo "UI version: $VERSION" |
| 107 | +
|
| 108 | + - name: Check if ui tag exists |
| 109 | + id: ui_tag |
| 110 | + run: | |
| 111 | + git fetch --tags |
| 112 | + if git rev-parse "qrlayout-ui@${{ steps.ui_pkg.outputs.version }}" >/dev/null 2>&1; then |
| 113 | + echo "exists=true" >> $GITHUB_OUTPUT |
| 114 | + echo "qrlayout-ui@${{ steps.ui_pkg.outputs.version }} already published — skipping" |
| 115 | + else |
| 116 | + echo "exists=false" >> $GITHUB_OUTPUT |
| 117 | + echo "qrlayout-ui@${{ steps.ui_pkg.outputs.version }} not found — will publish" |
| 118 | + fi |
| 119 | +
|
| 120 | + - name: Install dependencies |
| 121 | + if: steps.ui_tag.outputs.exists == 'false' |
| 122 | + run: npm ci |
| 123 | + |
| 124 | + - name: Build ui |
| 125 | + if: steps.ui_tag.outputs.exists == 'false' |
| 126 | + run: npm run build:ui |
| 127 | + |
| 128 | + - name: Publish qrlayout-ui |
| 129 | + if: steps.ui_tag.outputs.exists == 'false' |
| 130 | + run: | |
| 131 | + cd packages/ui |
| 132 | + echo "Publishing qrlayout-ui@${{ steps.ui_pkg.outputs.version }}..." |
| 133 | + npm publish --access public |
| 134 | + echo "Done!" |
| 135 | + env: |
| 136 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 137 | + |
| 138 | + - name: Create GitHub Release for ui |
| 139 | + if: steps.ui_tag.outputs.exists == 'false' |
| 140 | + uses: softprops/action-gh-release@v2 |
| 141 | + with: |
| 142 | + tag_name: qrlayout-ui@${{ steps.ui_pkg.outputs.version }} |
| 143 | + name: qrlayout-ui v${{ steps.ui_pkg.outputs.version }} |
| 144 | + body: | |
| 145 | + ## qrlayout-ui v${{ steps.ui_pkg.outputs.version }} |
| 146 | +
|
| 147 | + ### Install |
| 148 | + ```bash |
| 149 | + npm i qrlayout-ui |
| 150 | + ``` |
| 151 | +
|
| 152 | + See [CHANGELOG](https://github.com/shashi089/qr-code-layout-generate-tool/blob/main/packages/ui/CHANGELOG.md) for details. |
| 153 | + draft: false |
| 154 | + prerelease: false |
| 155 | + env: |
| 156 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments