|
| 1 | +name: TOSA Adapter for Model Explorer CI |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: ["main"] |
| 5 | + tags: |
| 6 | + - "v*.*.*" |
| 7 | + pull_request: |
| 8 | + branches: ["main"] |
| 9 | + workflow_dispatch: |
| 10 | +env: |
| 11 | + BUILD_PYTHON_VERSION: "3.12" |
| 12 | + ME_REPO_ACCESS_APP_ID: ${{ secrets.ME_REPO_ACCESS_APP_ID }} |
| 13 | + ME_REPO_ACCESS_PRIVATE_KEY: ${{ secrets.ME_REPO_ACCESS_PRIVATE_KEY }} |
| 14 | + |
| 15 | +jobs: |
| 16 | + test: |
| 17 | + strategy: |
| 18 | + fail-fast: false |
| 19 | + matrix: |
| 20 | + python-version: ["3.12", "3.11", "3.10"] |
| 21 | + runs-on: ubuntu-latest |
| 22 | + steps: |
| 23 | + - name: Set up Python environment |
| 24 | + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 |
| 25 | + with: |
| 26 | + python-version: ${{ matrix.python-version }} |
| 27 | + |
| 28 | + - name: Checkout plugin repo |
| 29 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 30 | + with: |
| 31 | + path: tosa-adapter-model-explorer |
| 32 | + |
| 33 | + - name: Install plugin Python packages |
| 34 | + run: | |
| 35 | + cd tosa-adapter-model-explorer |
| 36 | + python -m venv .venv |
| 37 | + source .venv/bin/activate |
| 38 | + python -m pip install .[test] |
| 39 | +
|
| 40 | + - name: Run plugin tests |
| 41 | + run: | |
| 42 | + cd tosa-adapter-model-explorer |
| 43 | + source .venv/bin/activate |
| 44 | + pytest --tb=short -v |
| 45 | +
|
| 46 | + build: |
| 47 | + needs: test |
| 48 | + runs-on: ubuntu-latest |
| 49 | + steps: |
| 50 | + - name: Set up Python environment |
| 51 | + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 |
| 52 | + with: |
| 53 | + python-version: ${{ env.BUILD_PYTHON_VERSION }} |
| 54 | + |
| 55 | + - name: Checkout plugin repo |
| 56 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 57 | + with: |
| 58 | + path: tosa-adapter-model-explorer |
| 59 | + |
| 60 | + - name: Install plugin Python packages |
| 61 | + run: | |
| 62 | + cd tosa-adapter-model-explorer |
| 63 | + python -m venv .venv |
| 64 | + source .venv/bin/activate |
| 65 | + python -m pip install .[build] |
| 66 | +
|
| 67 | + - name: Build plugin package |
| 68 | + run: | |
| 69 | + cd tosa-adapter-model-explorer |
| 70 | + source .venv/bin/activate |
| 71 | + python -m build |
| 72 | +
|
| 73 | + - name: Upload plugin package artifact |
| 74 | + uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 |
| 75 | + with: |
| 76 | + name: dist |
| 77 | + path: tosa-adapter-model-explorer/dist |
| 78 | + |
| 79 | + release: |
| 80 | + name: Release |
| 81 | + if: startsWith(github.ref, 'refs/tags/') && github.repository_owner == 'arm' |
| 82 | + needs: |
| 83 | + - build |
| 84 | + runs-on: ubuntu-latest |
| 85 | + environment: |
| 86 | + name: pypi |
| 87 | + url: https://pypi.org/p/tosa-adapter-model-explorer |
| 88 | + permissions: |
| 89 | + id-token: write |
| 90 | + |
| 91 | + steps: |
| 92 | + - uses: getsentry/action-github-app-token@d4b5da6c5e37703f8c3b3e43abb5705b46e159cc #v3.0.0 |
| 93 | + id: get_app_token |
| 94 | + with: |
| 95 | + app_id: ${{ env.ME_REPO_ACCESS_APP_ID }} |
| 96 | + private_key: ${{ env.ME_REPO_ACCESS_PRIVATE_KEY }} |
| 97 | + |
| 98 | + - uses: actions/checkout@v4 |
| 99 | + with: |
| 100 | + fetch-depth: 0 |
| 101 | + token: ${{ steps.get_app_token.outputs.token }} |
| 102 | + |
| 103 | + - name: Generate release notes |
| 104 | + uses: orhun/git-cliff-action@4a4a951bc43fafe41cd2348d181853f52356bee7 # v4.4.2 |
| 105 | + id: git-cliff |
| 106 | + with: |
| 107 | + config: cliff.toml |
| 108 | + args: --latest |
| 109 | + env: |
| 110 | + OUTPUT: CHANGELOG.md |
| 111 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 112 | + GITHUB_REPO: ${{ github.repository }} |
| 113 | + |
| 114 | + - name: Download all artifacts |
| 115 | + uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 |
| 116 | + with: |
| 117 | + path: dist/ |
| 118 | + merge-multiple: true |
| 119 | + |
| 120 | + - name: Publish distribution to PyPI |
| 121 | + uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # release/v1.12.4 |
| 122 | + |
| 123 | + - name: Publish GitHub release |
| 124 | + uses: softprops/action-gh-release@72f2c25fcb47643c292f7107632f7a47c1df5cd8 # v2.3.2 |
| 125 | + with: |
| 126 | + tag_name: ${{ github.ref_name }} |
| 127 | + name: ${{ github.ref_name }} |
| 128 | + body_path: CHANGELOG.md |
| 129 | + token: ${{ steps.get_app_token.outputs.token }} |
| 130 | + |
| 131 | + sync-commits-to-public-repo: |
| 132 | + name: Sync commits to public repo |
| 133 | + if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository_owner != 'arm' |
| 134 | + needs: build |
| 135 | + runs-on: ubuntu-latest |
| 136 | + steps: |
| 137 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 138 | + with: |
| 139 | + fetch-depth: 0 |
| 140 | + - name: Checkout target repository |
| 141 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 142 | + with: |
| 143 | + repository: arm/tosa-adapter-model-explorer |
| 144 | + token: ${{ secrets.ARM_ORG_TOKEN }} |
| 145 | + path: target-repo |
| 146 | + - name: Push commits to public repo |
| 147 | + run: | |
| 148 | + cd target-repo |
| 149 | + git remote add source ${{ github.server_url }}/${{ github.repository }} |
| 150 | + git fetch source main |
| 151 | + git checkout main |
| 152 | + git merge source/main |
| 153 | + git push origin main |
| 154 | +
|
| 155 | + sync-release-tags-to-public-repo: |
| 156 | + name: Sync release tags to public repo |
| 157 | + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && github.repository_owner != 'arm' |
| 158 | + runs-on: ubuntu-latest |
| 159 | + steps: |
| 160 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 161 | + with: |
| 162 | + fetch-depth: 0 |
| 163 | + - name: Checkout target repository |
| 164 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 165 | + with: |
| 166 | + repository: arm/tosa-adapter-model-explorer |
| 167 | + token: ${{ secrets.ARM_ORG_TOKEN }} |
| 168 | + path: target-repo |
| 169 | + - name: Push tags to public repo |
| 170 | + run: | |
| 171 | + cd target-repo |
| 172 | + git remote add source ${{ github.server_url }}/${{ github.repository }} |
| 173 | + git fetch source --tags |
| 174 | + git push origin ${{ github.ref_name }} |
0 commit comments