File: build.yml

package info (click to toggle)
zabbix-cli 3.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,980 kB
  • sloc: python: 19,920; makefile: 5
file content (228 lines) | stat: -rw-r--r-- 6,836 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
name: build zabbix-cli

on:
  push:
    tags:
      - "[0-9]+.[0-9]+.[0-9]+*"

concurrency:
  group: build-zabbix-cli-${{ github.head_ref }}

env:
  UV_FROZEN: 1

jobs:
  build_pypi:
    name: Build wheels and source distribution
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - name: Install uv
        uses: astral-sh/setup-uv@v2

      - name: Set up Python 3.12
        run: uv python install 3.12

      - name: Install project dependencies only
        run: uv sync --no-dev

      - name: Build source and wheel distributions
        run: uv build

      - uses: actions/upload-artifact@v4
        with:
          name: pypi_artifacts
          path: dist/*
          if-no-files-found: error

  build_pyinstaller:
    name: Build pyinstaller binary
    strategy:
      matrix:
        os:
          - ubuntu-latest
          - windows-latest
          - macos-15-intel
          - macos-latest
        include:
          - os: ubuntu-latest
            platform: linux-x86_64
            container: redhat/ubi8:latest
          - os: windows-latest
            platform: win-x86_64
          - os: macos-15-intel
            platform: macos-x86_64
          - os: macos-latest
            platform: macos-arm64
        python-version:
          - "3.12"
    runs-on: ${{ matrix.os }}
    container:
      image: ${{ matrix.container }}

    steps:
      - name: Install RHEL 8 dependencies
        if: contains(matrix.container, 'redhat/ubi8')
        run: dnf install -y git binutils

      - name: Ensure git is available
        run: git --version

      - uses: actions/checkout@v4

      - name: Install uv
        uses: astral-sh/setup-uv@v2

      - name: Set up Python ${{ matrix.python-version }}
        run: uv python install ${{ matrix.python-version }}

      - name: Install build dependencies
        run: uv sync --group build --no-dev

      - name: Build binary with PyInstaller
        run: uv run pyinstaller --onefile zabbix_cli/main.py --name zabbix-cli

      - name: Set platform binary names
        shell: bash
        run: |
          VERSION="${{ github.ref_name }}"
          BASE_NAME="zabbix-cli-${VERSION}-${{ matrix.platform }}"
          if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
            echo "BINARY_NAME=${BASE_NAME}.exe" >> $GITHUB_ENV
            echo "SOURCE_NAME=dist/zabbix-cli.exe" >> $GITHUB_ENV
          else
            echo "BINARY_NAME=${BASE_NAME}" >> $GITHUB_ENV
            echo "SOURCE_NAME=dist/zabbix-cli" >> $GITHUB_ENV
          fi

      - name: Rename binary
        shell: bash
        run: mv "${{ env.SOURCE_NAME }}" "dist/${{ env.BINARY_NAME }}"

      - uses: actions/upload-artifact@v4
        with:
          name: ${{ env.BINARY_NAME }}
          path: dist/${{ env.BINARY_NAME }}
          if-no-files-found: error

  publish_github:
    name: Publish GitHub release
    needs:
      - build_pypi
      - build_pyinstaller
    runs-on: ubuntu-latest

    steps:
      - name: Download PyInstaller binaries
        uses: actions/download-artifact@v4
        with:
          pattern: zabbix-cli-*
          path: dist
          merge-multiple: true

      - name: Download wheel and source distributions
        uses: actions/download-artifact@v4
        with:
          pattern: pypi_artifacts
          path: dist
          merge-multiple: true

      - name: Generate SHA256 checksums
        id: sha
        run: |
          cd dist
          echo "checksums<<EOF" >> $GITHUB_OUTPUT
          sha256sum * >> $GITHUB_OUTPUT
          echo "EOF" >> $GITHUB_OUTPUT

      - name: Create GitHub release
        uses: softprops/action-gh-release@v2
        with:
          files: dist/*
          body: |
            Release ${{ github.ref_name }}

            ## Binary Downloads

            Platform | Architecture | Download
            ---------|--------------|----------
            Linux | x86_64 | [zabbix-cli-${{ github.ref_name }}-linux-x86_64](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/zabbix-cli-${{ github.ref_name }}-linux-x86_64)
            Windows | x86_64 | [zabbix-cli-${{ github.ref_name }}-win-x86_64.exe](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/zabbix-cli-${{ github.ref_name }}-win-x86_64.exe)
            macOS | x86_64 | [zabbix-cli-${{ github.ref_name }}-macos-x86_64](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/zabbix-cli-${{ github.ref_name }}-macos-x86_64)
            macOS | ARM64 | [zabbix-cli-${{ github.ref_name }}-macos-arm64](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/zabbix-cli-${{ github.ref_name }}-macos-arm64)

            ## PyPI Package

            ### uv

            ```bash
            uv tool install zabbix-cli-uio==${{ github.ref_name }}
            ```

            ### pipx

            ```bash
            pipx install zabbix-cli-uio==${{ github.ref_name }}
            ```

            ### pip

            ```bash
            pip install zabbix-cli-uio==${{ github.ref_name }}
            ```

            ## SHA256 Checksums
            ```
            ${{ steps.sha.outputs.checksums }}
            ```
          draft: false
          prerelease: false

  publish_pypi:
    name: Publish PyPI release
    needs:
      - build_pypi
      - publish_github
    runs-on: ubuntu-latest
    permissions:
      id-token: write
    steps:
      - uses: actions/download-artifact@v4
        with:
          name: pypi_artifacts
          path: dist

      - name: Push build artifacts to PyPI
        uses: pypa/gh-action-pypi-publish@release/v1

  rollback_on_failure:
    name: Rollback on publish failure
    if: ${{ always() && (needs.publish_github.result == 'failure' || needs.publish_pypi.result == 'failure') }}
    needs:
      - publish_github
      - publish_pypi
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: Rollback GitHub release and tag
        if: ${{ needs.publish_github.result == 'success' }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          echo "Deleting GitHub release..."
          gh release delete ${{ github.ref_name }} --repo ${{ github.repository }} --yes || true

          echo "Deleting git tag..."
          git push --delete origin "refs/tags/${{ github.ref_name }}" || true
      - name: Rollback notification
        run: |
          echo "::notice::Rolling back release ${{ github.ref_name }} due to publish failure"
          echo "GitHub release status: ${{ needs.publish_github.result }}"
          echo "PyPI publish status: ${{ needs.publish_pypi.result }}"