|
| 1 | +name: "Publish" |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - main |
| 6 | + paths-ignore: |
| 7 | + - ".github/workflows/**" |
| 8 | + |
| 9 | +permissions: |
| 10 | + id-token: write # Required for OIDC |
| 11 | + contents: read |
| 12 | + |
| 13 | +concurrency: |
| 14 | + group: publish |
| 15 | + cancel-in-progress: false |
| 16 | + |
| 17 | +jobs: |
| 18 | + |
| 19 | + pre-ci: |
| 20 | + name: Pre-CI (Extract Commit Message) |
| 21 | + runs-on: ubuntu-latest |
| 22 | + timeout-minutes: 1 |
| 23 | + outputs: |
| 24 | + commit-message: ${{ steps.get_commit_message.outputs.commit-message }} |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v5 |
| 27 | + with: |
| 28 | + fetch-depth: 0 |
| 29 | + |
| 30 | + - id: get_commit_message |
| 31 | + run: | |
| 32 | + COMMIT_MSG_TEMP="${{ github.event.head_commit.message }}" |
| 33 | + if [ -n "$COMMIT_MSG_TEMP" ] |
| 34 | + then |
| 35 | + commit_msg="$COMMIT_MSG_TEMP" |
| 36 | + echo "commit-message=${commit_msg}" | head -n 1 >> "$GITHUB_OUTPUT" |
| 37 | + else |
| 38 | + commit_message=$(git log -1 --pretty=%B | head -n 1) |
| 39 | + echo "commit-message=$commit_message" >> "$GITHUB_OUTPUT" |
| 40 | + fi |
| 41 | +
|
| 42 | + - name: Debug commit message |
| 43 | + run: | |
| 44 | + echo "Commit message: ${{ steps.get_commit_message.outputs.commit-message }}" |
| 45 | +
|
| 46 | + setup: |
| 47 | + name: Setup & Detect Changes |
| 48 | + needs: pre-ci |
| 49 | + runs-on: ubuntu-latest |
| 50 | + outputs: |
| 51 | + changed-types: ${{ steps.changed-types.outputs.changed }} |
| 52 | + changed-common-solana: ${{ steps.changed-common-solana.outputs.changed }} |
| 53 | + changed-node: ${{ steps.changed-node.outputs.changed }} |
| 54 | + steps: |
| 55 | + - uses: actions/checkout@v5 |
| 56 | + with: |
| 57 | + fetch-depth: 100 # Needed to detect changes by having commit history |
| 58 | + |
| 59 | + - uses: marceloprado/has-changed-path@v1 |
| 60 | + id: changed-types |
| 61 | + with: |
| 62 | + paths: packages/types |
| 63 | + |
| 64 | + - uses: marceloprado/has-changed-path@v1 |
| 65 | + id: changed-common-solana |
| 66 | + with: |
| 67 | + paths: packages/common-solana |
| 68 | + |
| 69 | + - uses: marceloprado/has-changed-path@v1 |
| 70 | + id: changed-node |
| 71 | + with: |
| 72 | + paths: packages/node |
| 73 | + |
| 74 | + release: |
| 75 | + name: Release Publish |
| 76 | + needs: [pre-ci, setup] |
| 77 | + if: > |
| 78 | + !startsWith(github.event.head_commit.message, '[SKIP CI]') |
| 79 | + && startsWith(github.event.head_commit.message, '[release]') |
| 80 | + && github.repository == 'subquery/subql-solana' |
| 81 | + runs-on: ubuntu-latest |
| 82 | + steps: |
| 83 | + - uses: actions/checkout@v5 |
| 84 | + with: |
| 85 | + fetch-depth: 0 |
| 86 | + |
| 87 | + - name: Setup Node.js environment |
| 88 | + uses: actions/setup-node@v5 |
| 89 | + with: |
| 90 | + node-version: lts/* |
| 91 | + |
| 92 | + - name: Update npm |
| 93 | + run: npm install -g npm@latest |
| 94 | + |
| 95 | + - run: yarn |
| 96 | + |
| 97 | + - name: build |
| 98 | + run: yarn build |
| 99 | + |
| 100 | + # Publish to npm and github releases |
| 101 | + - name: Publish Types |
| 102 | + if: needs.setup.outputs.changed-types == 'true' |
| 103 | + uses: ./.github/actions/create-release |
| 104 | + with: |
| 105 | + package-path: packages/types |
| 106 | + repo-token: ${{ secrets.REPO_TOKEN }} |
| 107 | + |
| 108 | + - name: Publish Common Solana |
| 109 | + if: needs.setup.outputs.changed-common-solana == 'true' |
| 110 | + uses: ./.github/actions/create-release |
| 111 | + with: |
| 112 | + package-path: packages/common-solana |
| 113 | + repo-token: ${{ secrets.REPO_TOKEN }} |
| 114 | + |
| 115 | + - name: Publish Node |
| 116 | + if: needs.setup.outputs.changed-node == 'true' |
| 117 | + uses: ./.github/actions/create-release |
| 118 | + with: |
| 119 | + package-path: packages/node |
| 120 | + repo-token: ${{ secrets.REPO_TOKEN }} |
| 121 | + |
| 122 | + prerelease: |
| 123 | + name: Prerelease Publish |
| 124 | + needs: [pre-ci, setup] |
| 125 | + if: > |
| 126 | + !startsWith(needs.pre-ci.outputs.commit-message, '[SKIP CI]') |
| 127 | + && !startsWith(needs.pre-ci.outputs.commit-message, '[release]') |
| 128 | + && github.repository == 'subquery/subql-solana' |
| 129 | + runs-on: ubuntu-latest |
| 130 | + steps: |
| 131 | + - uses: actions/checkout@v5 |
| 132 | + with: |
| 133 | + fetch-depth: 0 |
| 134 | + token: ${{ secrets.REPO_TOKEN }} # Needed to push changes back to repo |
| 135 | + |
| 136 | + - name: Setup Node.js environment |
| 137 | + uses: actions/setup-node@v5 |
| 138 | + with: |
| 139 | + node-version: lts/* |
| 140 | + |
| 141 | + - name: Update npm |
| 142 | + run: npm install -g npm@latest |
| 143 | + |
| 144 | + - run: yarn |
| 145 | + |
| 146 | + - name: build |
| 147 | + run: yarn build |
| 148 | + |
| 149 | + # Prerelease publish steps |
| 150 | + - name: Bump types & deploy |
| 151 | + if: needs.setup.outputs.changed-types == 'true' |
| 152 | + uses: ./.github/actions/create-prerelease |
| 153 | + with: |
| 154 | + package-path: packages/types |
| 155 | + |
| 156 | + - name: Bump common Solana & deploy |
| 157 | + if: needs.setup.outputs.changed-common-solana == 'true' |
| 158 | + uses: ./.github/actions/create-prerelease |
| 159 | + with: |
| 160 | + package-path: packages/common-solana |
| 161 | + |
| 162 | + - name: Bump node & deploy |
| 163 | + if: needs.setup.outputs.changed-node == 'true' |
| 164 | + uses: ./.github/actions/create-prerelease |
| 165 | + with: |
| 166 | + package-path: packages/node |
| 167 | + |
| 168 | + |
| 169 | + - name: Commit changes |
| 170 | + uses: EndBug/add-and-commit@v9 |
| 171 | + with: |
| 172 | + message: "[SKIP CI] Prerelease" |
| 173 | + default_author: github_actions |
0 commit comments