|
4 | 4 | push: |
5 | 5 | branches: [main] |
6 | 6 | paths: |
7 | | - - 'packages/openapi/**' |
| 7 | + - "packages/openapi/**" |
8 | 8 |
|
9 | 9 | jobs: |
10 | | - trigger: |
| 10 | + pack: |
11 | 11 | runs-on: ubuntu-latest |
12 | 12 | environment: production |
| 13 | + permissions: |
| 14 | + contents: read |
| 15 | + outputs: |
| 16 | + version: ${{ steps.set-outputs.outputs.version }} |
| 17 | + packfile_name: ${{ steps.set-outputs.outputs.packfile_name }} |
| 18 | + steps: |
| 19 | + - name: Checkout |
| 20 | + uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - name: Setup Node.js |
| 23 | + uses: actions/setup-node@v4 |
| 24 | + with: |
| 25 | + node-version: "20" |
| 26 | + |
| 27 | + - id: set-outputs |
| 28 | + name: Pack @docs/openapi and upload artifacts |
| 29 | + run: | |
| 30 | + set -euo pipefail |
| 31 | + cd packages/openapi |
| 32 | +
|
| 33 | + echo "Working dir: $(pwd)" |
| 34 | + cat package.json |
| 35 | +
|
| 36 | + npm ci |
| 37 | +
|
| 38 | + # npm pack prints the filename; grab the last non-empty line |
| 39 | + PACKFILE=$(npm pack | sed -n '/./p' | tail -n1) |
| 40 | + echo "Packed file: $PACKFILE" |
| 41 | +
|
| 42 | + # create stable 'latest' name |
| 43 | + LATEST_NAME="openapi-latest.tgz" |
| 44 | + cp -f "$PACKFILE" "$LATEST_NAME" |
| 45 | +
|
| 46 | + # ensure files exist |
| 47 | + ls -la |
| 48 | +
|
| 49 | + VERSION=$(node -p "require('./package.json').version") |
| 50 | + echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
| 51 | + echo "packfile_name=$PACKFILE" >> "$GITHUB_OUTPUT" |
| 52 | +
|
| 53 | + - name: Upload tarballs as artifact |
| 54 | + uses: actions/upload-artifact@v4 |
| 55 | + with: |
| 56 | + name: openapi-tarballs |
| 57 | + path: | |
| 58 | + packages/openapi/${{ steps.set-outputs.outputs.packfile_name }} |
| 59 | + packages/openapi/openapi-latest.tgz |
| 60 | +
|
| 61 | + release-openapi-packages: |
| 62 | + runs-on: ubuntu-latest |
| 63 | + needs: pack |
| 64 | + environment: production |
| 65 | + permissions: |
| 66 | + contents: write |
| 67 | + steps: |
| 68 | + - name: Checkout (needed for workspace) |
| 69 | + uses: actions/checkout@v4 |
| 70 | + |
| 71 | + - name: Download packed artifacts |
| 72 | + uses: actions/download-artifact@v4 |
| 73 | + with: |
| 74 | + name: openapi-tarballs |
| 75 | + path: artifacts |
| 76 | + |
| 77 | + - name: Show artifacts (debug) |
| 78 | + run: ls -la artifacts || true |
| 79 | + |
| 80 | + - name: Resolve artifact paths |
| 81 | + id: find |
| 82 | + run: | |
| 83 | + set -euo pipefail |
| 84 | + PACKFILE="${{ needs.pack.outputs.packfile_name }}" |
| 85 | + PACK_PATH=$(find artifacts -type f -name "$PACKFILE" -print -quit || true) |
| 86 | + LATEST_PATH=$(find artifacts -type f -name "openapi-latest.tgz" -print -quit || true) |
| 87 | +
|
| 88 | + echo "Found pack path: $PACK_PATH" |
| 89 | + echo "Found latest path: $LATEST_PATH" |
| 90 | + if [ -z "$PACK_PATH" ] || [ -z "$LATEST_PATH" ]; then |
| 91 | + echo "::error::Missing artifact(s). Debug listing:" |
| 92 | + ls -Rla artifacts || true |
| 93 | + exit 1 |
| 94 | + fi |
| 95 | +
|
| 96 | + echo "pack_path=$PACK_PATH" >> "$GITHUB_OUTPUT" |
| 97 | + echo "latest_path=$LATEST_PATH" >> "$GITHUB_OUTPUT" |
| 98 | +
|
| 99 | + - name: Create or update tagged release and upload versioned tarball |
| 100 | + id: gh_release_tag |
| 101 | + uses: softprops/action-gh-release@v1 |
| 102 | + with: |
| 103 | + tag_name: "openapi-v${{ needs.pack.outputs.version }}" |
| 104 | + name: "openapi v${{ needs.pack.outputs.version }}" |
| 105 | + body: "Automated release for packages/openapi (pack + upload)" |
| 106 | + files: ${{ steps.find.outputs.pack_path }} |
| 107 | + env: |
| 108 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 109 | + |
| 110 | + - name: Create or update 'latest' release and upload stable tarball |
| 111 | + id: gh_release_latest |
| 112 | + uses: softprops/action-gh-release@v1 |
| 113 | + with: |
| 114 | + tag_name: "openapi-latest" |
| 115 | + name: "openapi latest" |
| 116 | + body: "Automated release for packages/openapi (latest)" |
| 117 | + files: ${{ steps.find.outputs.latest_path }} |
| 118 | + env: |
| 119 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 120 | + |
| 121 | + rebuild-schema: |
| 122 | + runs-on: ubuntu-latest |
| 123 | + environment: production |
| 124 | + needs: |
| 125 | + - release-openapi-packages |
13 | 126 | steps: |
14 | 127 | - name: Trigger autoupdate swagger |
15 | 128 | env: |
|
0 commit comments