| name: Build Binary
|
|
|
| on:
|
| push:
|
| branches: [ main ]
|
|
|
| permissions:
|
| contents: write
|
| packages: write
|
|
|
| jobs:
|
| create-release:
|
| runs-on: ubuntu-latest
|
| outputs:
|
| version: ${{ steps.version.outputs.new_version }}
|
| steps:
|
| - uses: actions/checkout@v4
|
| with:
|
| fetch-depth: 0
|
|
|
| - name: Determine Version
|
| id: version
|
| run: |
|
|
|
| LATEST_TAG=$(gh release list -L 1 | cut -f 1 | sed 's/Release //' || echo "v0.0")
|
| LATEST_TAG=${LATEST_TAG:-v0.0}
|
|
|
|
|
| MAJOR=$(echo $LATEST_TAG | cut -d. -f1 | sed 's/v//')
|
| MINOR=$(echo $LATEST_TAG | cut -d. -f2)
|
|
|
|
|
| if git log -1 --pretty=%B | grep -i "version bump"; then
|
| NEW_VERSION="v$((MAJOR + 1)).0"
|
| else
|
| NEW_VERSION="v$MAJOR.$((MINOR + 1))"
|
| fi
|
|
|
| echo "Previous version: $LATEST_TAG"
|
| echo "New version: $NEW_VERSION"
|
| echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
|
| env:
|
| GH_TOKEN: ${{ github.token }}
|
|
|
| - name: Create Release
|
| id: create_release
|
| run: |
|
| COMMIT_MSG=$(git log -1 --pretty=%B)
|
|
|
| gh release create "${{ steps.version.outputs.new_version }}" \
|
| --title "Release ${{ steps.version.outputs.new_version }}" \
|
| --draft \
|
| --notes "$COMMIT_MSG" \
|
| --target ${{ github.sha }}
|
| env:
|
| GH_TOKEN: ${{ github.token }}
|
|
|
| build:
|
| needs: create-release
|
| runs-on: ${{ matrix.os }}
|
| strategy:
|
| matrix:
|
| os: [ubuntu-22.04, macos-latest]
|
| steps:
|
| - uses: actions/checkout@v4
|
|
|
| - name: Set up Python
|
| uses: actions/setup-python@v5
|
| with:
|
| python-version: '3.10'
|
|
|
| - name: Install dependencies
|
| run: |
|
| python -m pip install --upgrade pip
|
| pip install -r requirements.txt
|
| pip install pyinstaller
|
|
|
| - name: Build Binary
|
| run: |
|
| pyinstaller --onefile \
|
| --hidden-import=pydantic \
|
| --hidden-import=pydantic-core \
|
| --hidden-import=pydantic.deprecated.decorator \
|
| --hidden-import=backports \
|
| --hidden-import=backports.tarfile \
|
| --strip --noupx --name robin main.py
|
|
|
|
|
| - name: Archive Binary
|
| run: |
|
| cd dist/
|
| if [[ "${{ matrix.os }}" == "macos-latest" ]]; then
|
| zip robin-macos.zip robin ../LICENSE ../README.md
|
| else
|
| zip robin-linux.zip robin ../LICENSE ../README.md
|
| fi
|
|
|
| - name: Upload Release Asset
|
| run: |
|
| cd dist/
|
| if [[ "${{ matrix.os }}" == "macos-latest" ]]; then
|
| gh release upload "${{ needs.create-release.outputs.version }}" \
|
| "robin-macos.zip" --clobber
|
| else
|
| gh release upload "${{ needs.create-release.outputs.version }}" \
|
| "robin-linux.zip" --clobber
|
| fi
|
| env:
|
| GH_TOKEN: ${{ github.token }}
|
|
|
| publish:
|
| needs: [create-release, build]
|
| runs-on: ubuntu-latest
|
| steps:
|
| - uses: actions/checkout@v4
|
|
|
| - name: Publish Release
|
| run: |
|
| gh release edit "${{ needs.create-release.outputs.version }}" --draft=false
|
| env:
|
| GH_TOKEN: ${{ github.token }} |