|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main, beta, prerelease ] |
| 6 | + paths: |
| 7 | + - 'src/**' |
| 8 | + - 'package.json' |
| 9 | + - 'webpack.config.js' |
| 10 | + - 'tsconfig.json' |
| 11 | + - 'yarn.lock' |
| 12 | + workflow_dispatch: |
| 13 | + |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2 |
| 20 | + with: |
| 21 | + fetch-depth: 2 # Need previous commit to compare versions |
| 22 | + |
| 23 | + - name: Extract branch name |
| 24 | + shell: bash |
| 25 | + run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT |
| 26 | + id: extract_branch |
| 27 | + |
| 28 | + - name: Check if version changed |
| 29 | + id: version_check |
| 30 | + run: | |
| 31 | + OLD_VERSION=$(git show HEAD~1:package.json 2>/dev/null | jq -r '.version' || echo "0.0.0") |
| 32 | + NEW_VERSION=$(jq -r '.version' package.json) |
| 33 | + echo "old_version=$OLD_VERSION" |
| 34 | + echo "new_version=$NEW_VERSION" |
| 35 | + if [ "$OLD_VERSION" != "$NEW_VERSION" ]; then |
| 36 | + echo "Version changed from $OLD_VERSION to $NEW_VERSION" |
| 37 | + echo "changed=true" >> $GITHUB_OUTPUT |
| 38 | + else |
| 39 | + echo "Version unchanged ($NEW_VERSION)" |
| 40 | + echo "changed=false" >> $GITHUB_OUTPUT |
| 41 | + fi |
| 42 | +
|
| 43 | + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # 4.4.0 |
| 44 | + with: |
| 45 | + node-version: '22.13.0' |
| 46 | + - run: yarn |
| 47 | + - run: yarn build:setup |
| 48 | + - run: yarn prepare-beta |
| 49 | + if: ${{ steps.extract_branch.outputs.branch == 'beta' }} |
| 50 | + - run: xvfb-run -a yarn test |
| 51 | + - run: yarn run prettier:check |
| 52 | + - run: yarn run lint |
| 53 | + - name: Publish to Visual Studio Marketplace |
| 54 | + if: ${{ (steps.version_check.outputs.changed == 'true' || github.event_name == 'workflow_dispatch') && steps.extract_branch.outputs.branch != 'prerelease' }} |
| 55 | + |
| 56 | + with: |
| 57 | + pat: ${{ secrets.VS_MARKETPLACE_TOKEN }} |
| 58 | + registryUrl: https://marketplace.visualstudio.com |
| 59 | + yarn: true |
| 60 | + |
| 61 | + - name: Publish to Visual Studio Marketplace for pre-release |
| 62 | + if: ${{ (steps.version_check.outputs.changed == 'true' || github.event_name == 'workflow_dispatch') && steps.extract_branch.outputs.branch == 'prerelease' }} |
| 63 | + |
| 64 | + with: |
| 65 | + pat: ${{ secrets.VS_MARKETPLACE_TOKEN }} |
| 66 | + registryUrl: https://marketplace.visualstudio.com |
| 67 | + yarn: true |
| 68 | + preRelease: true |
| 69 | + |
| 70 | + - name: Publish to Open VSX Registry |
| 71 | + if: ${{ steps.version_check.outputs.changed == 'true' || github.event_name == 'workflow_dispatch' }} |
| 72 | + uses: HaaLeo/publish-vscode-extension@v0 |
| 73 | + with: |
| 74 | + pat: ${{ secrets.OPEN_VSX_TOKEN }} |
| 75 | + yarn: true |
0 commit comments