|
| 1 | +name: Publish and Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | +env: |
| 9 | + TELEMETRY_TRACKING_TOKEN: ${{ secrets.TELEMETRY_TRACKING_TOKEN }} |
| 10 | + DO_NOT_TRACK: "1" |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: write |
| 14 | + |
| 15 | +jobs: |
| 16 | + publish-and-release: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Checkout |
| 21 | + uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - name: Install pnpm |
| 24 | + uses: pnpm/action-setup@v2 |
| 25 | + with: |
| 26 | + version: 10.12.1 |
| 27 | + |
| 28 | + - name: Use Node.js |
| 29 | + uses: actions/setup-node@v4 |
| 30 | + with: |
| 31 | + node-version: 20.x |
| 32 | + cache: "pnpm" |
| 33 | + registry-url: "https://registry.npmjs.org" |
| 34 | + |
| 35 | + - name: Install dependencies |
| 36 | + run: pnpm install --frozen-lockfile |
| 37 | + |
| 38 | + - name: Build |
| 39 | + run: | |
| 40 | + pnpm run build |
| 41 | + pnpm tsx scripts/post-build.ts |
| 42 | +
|
| 43 | + - name: Get version from package.json |
| 44 | + id: version |
| 45 | + run: | |
| 46 | + VERSION=$(node -p "require('./package.json').version") |
| 47 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 48 | + echo "tag=v$VERSION" >> $GITHUB_OUTPUT |
| 49 | +
|
| 50 | + - name: Publish packages |
| 51 | + run: pnpm run publish-all |
| 52 | + env: |
| 53 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 54 | + |
| 55 | + - name: Generate changelog |
| 56 | + id: changelog |
| 57 | + run: | |
| 58 | + PREVIOUS_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") |
| 59 | +
|
| 60 | + if [ -z "$PREVIOUS_TAG" ]; then |
| 61 | + CHANGELOG=$(git log --oneline --no-merges --format="* %s" HEAD) |
| 62 | + else |
| 63 | + CHANGELOG=$(git log --oneline --no-merges --format="* %s" ${PREVIOUS_TAG}..HEAD) |
| 64 | + fi |
| 65 | +
|
| 66 | + if [ -z "$CHANGELOG" ]; then |
| 67 | + CHANGELOG="* Automated release" |
| 68 | + fi |
| 69 | +
|
| 70 | + echo "changelog<<EOF" >> $GITHUB_OUTPUT |
| 71 | + echo "$CHANGELOG" >> $GITHUB_OUTPUT |
| 72 | + echo "EOF" >> $GITHUB_OUTPUT |
| 73 | +
|
| 74 | + - name: Create GitHub Release |
| 75 | + uses: softprops/action-gh-release@v2 |
| 76 | + env: |
| 77 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 78 | + with: |
| 79 | + tag_name: ${{ steps.version.outputs.tag }} |
| 80 | + name: ZenStack Proxy Release ${{ steps.version.outputs.tag }} |
| 81 | + body: | |
| 82 | + ## Changes in this release |
| 83 | +
|
| 84 | + ${{ steps.changelog.outputs.changelog }} |
| 85 | + draft: true |
0 commit comments