|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + workflow_dispatch: |
| 11 | + merge_group: |
| 12 | + release: |
| 13 | + types: [published] |
| 14 | + |
| 15 | +jobs: |
| 16 | + build: |
| 17 | + name: Build and test |
| 18 | + runs-on: [ubuntu-latest] |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 21 | + with: |
| 22 | + fetch-depth: 0 |
| 23 | + submodules: true |
| 24 | + |
| 25 | + - uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0 |
| 26 | + with: |
| 27 | + node-version-file: package.json |
| 28 | + registry-url: https://npm.pkg.github.com |
| 29 | + always-auth: true |
| 30 | + cache: 'yarn' |
| 31 | + |
| 32 | + - name: Set version |
| 33 | + run: | |
| 34 | + case ${{ github.event_name }} in |
| 35 | + release) |
| 36 | + TAG="${{ github.event.release.tag_name }}" |
| 37 | + yarn version --no-git-tag-version --new-version "${TAG#v}" |
| 38 | + ;; |
| 39 | + pull_request) |
| 40 | + DESCRIBE=$(git describe --tags | grep -Eo 'v[0-9]+\.[0-9]+\.[0-9]+') |
| 41 | + QUALIFIER=$(git describe --tags | grep -Eo '\-g[0-9a-f]+$') |
| 42 | + yarn version -s --no-git-tag-version --new-version "${DESCRIBE#v}" |
| 43 | + yarn version --no-git-tag-version --prepatch --preid "pr${{ github.event.number }}${QUALIFIER}" |
| 44 | + ;; |
| 45 | + *) |
| 46 | + DESCRIBE=$(git describe --tags | grep -Eo 'v[0-9]+\.[0-9]+\.[0-9]+') |
| 47 | + QUALIFIER=$(git describe --tags | grep -Eo '[0-9]+\-g[0-9a-f]+$') |
| 48 | + yarn version -s --no-git-tag-version --new-version "${DESCRIBE#v}" |
| 49 | + yarn version --no-git-tag-version --prepatch --preid "${{ github.ref_name }}${QUALIFIER}" |
| 50 | + ;; |
| 51 | + esac |
| 52 | + VERSION="$(jq -r ".version" < package.json)" |
| 53 | + sed -i "s/## Unreleased/## ${VERSION}/" CHANGELOG.md |
| 54 | + echo "Version is ${VERSION}" |
| 55 | +
|
| 56 | + - name: Remove Badges for dist |
| 57 | + run: | |
| 58 | + sed -i "/https:\/\/codeclimate\.com\/github\/Open\-CMSIS\-Pack\/vscode\-cmsis\-debugger/d" README.md |
| 59 | +
|
| 60 | + - name: Build |
| 61 | + env: |
| 62 | + GITHUB_TOKEN: ${{github.token}} |
| 63 | + run: yarn --frozen-lockfile --prefer-offline |
| 64 | + |
| 65 | + - name: Test |
| 66 | + run: yarn test |
| 67 | + |
| 68 | + - name: Upload dist |
| 69 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 70 | + with: |
| 71 | + name: dist |
| 72 | + path: | |
| 73 | + ./README.md |
| 74 | + ./CHANGELOG.md |
| 75 | + ./package.json |
| 76 | + ./dist |
| 77 | + retention-days: 1 |
| 78 | + |
| 79 | + - name: Commit changelog |
| 80 | + if: false && github.event_name == 'release' |
| 81 | + run: | |
| 82 | + sed -i '3i ## Unreleased\n' CHANGELOG.md |
| 83 | + git checkout main |
| 84 | + git config user.name github-actions |
| 85 | + git config user.email [email protected] |
| 86 | + git add CHANGELOG.md |
| 87 | + git commit -m "Update CHANGELOG.md after release [skip ci]" |
| 88 | + git push |
| 89 | +
|
| 90 | + - name: Publish coverage report to Code Climate |
| 91 | + uses: paambaati/codeclimate-action@f429536ee076d758a24705203199548125a28ca7 # v9.0.0 |
| 92 | + env: |
| 93 | + CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}} |
| 94 | + with: |
| 95 | + debug: true |
| 96 | + coverageLocations: coverage/lcov.info:lcov |
| 97 | + |
| 98 | + package: |
| 99 | + name: Package |
| 100 | + runs-on: [ubuntu-latest] |
| 101 | + needs: build |
| 102 | + strategy: |
| 103 | + fail-fast: true |
| 104 | + matrix: |
| 105 | + target: |
| 106 | + - win32-x64 |
| 107 | + - linux-x64 |
| 108 | + - linux-arm64 |
| 109 | + - darwin-arm64 |
| 110 | + steps: |
| 111 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 112 | + |
| 113 | + - uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0 |
| 114 | + with: |
| 115 | + node-version-file: package.json |
| 116 | + registry-url: https://npm.pkg.github.com |
| 117 | + always-auth: true |
| 118 | + cache: 'yarn' |
| 119 | + |
| 120 | + - name: Download dist |
| 121 | + uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 |
| 122 | + with: |
| 123 | + name: dist |
| 124 | + path: . |
| 125 | + |
| 126 | + - name: Cache tools |
| 127 | + uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.6 |
| 128 | + with: |
| 129 | + path: tools |
| 130 | + key: tools-${{ matrix.target }}-${{ github.head_ref || github.ref_name }} |
| 131 | + restore-keys: | |
| 132 | + tools-${{ matrix.target }}-${{ github.base_ref || 'main' }} |
| 133 | + tools-${{ matrix.target }}- |
| 134 | +
|
| 135 | + - name: Download tools |
| 136 | + run: | |
| 137 | + yarn --frozen-lockfile --ignore-scripts --prefer-offline |
| 138 | + yarn download-tools --target ${{ matrix.target }} --no-cache |
| 139 | +
|
| 140 | + - name: Create vsix package (pre-release) |
| 141 | + run: | |
| 142 | + yarn package --target ${{ matrix.target }} --pre-release |
| 143 | +
|
| 144 | + - name: Upload package |
| 145 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 146 | + with: |
| 147 | + name: vsix-package-${{ matrix.target }} |
| 148 | + path: ./*.vsix |
| 149 | + retention-days: 1 |
| 150 | + |
| 151 | + publish: |
| 152 | + name: Publish release |
| 153 | + runs-on: [ubuntu-latest] |
| 154 | + if: github.event_name == 'release' |
| 155 | + needs: package |
| 156 | + steps: |
| 157 | + - name: Download packages |
| 158 | + uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 |
| 159 | + with: |
| 160 | + pattern: vsix-package-* |
| 161 | + |
| 162 | + - name: Attach packages |
| 163 | + uses: softprops/action-gh-release@da05d552573ad5aba039eaac05058a918a7bf631 # v2.2.2 |
| 164 | + with: |
| 165 | + files: "**/*.vsix" |
0 commit comments