Merge branch 'master' of https://github.com/CodeThreat/codethreat-cli #42
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
bump_version: | |
if: "!startsWith(github.event.head_commit.message, 'bump:')" | |
runs-on: ubuntu-latest | |
name: "Bump version and create changelog with commitizen" | |
outputs: | |
revision: ${{ steps.cz.outputs.version }} | |
changelog: ${{ steps.cz.outputs.changelog_path }} | |
steps: | |
- name: Check out | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
token: "${{ secrets.GITHUB_TOKEN }}" | |
- id: cz | |
name: Create bump and changelog | |
uses: commitizen-tools/commitizen-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
changelog_increment_filename: body.md | |
- name: List files in dist directory | |
run: ls -lR . | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: body.md | |
path: | | |
body.md | |
- name: Set Outputs | |
run: | | |
echo "REVISION=${{ steps.cz.outputs.version }}" >> $GITHUB_ENV | |
echo "CHANGELOG_PATH=changelog-${{ steps.cz.outputs.version }}.md" >> $GITHUB_ENV | |
id: set_output | |
build: | |
needs: bump_version | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
architecture: [x86_64, arm64] | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.12' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install pyinstaller | |
- name: Build executables | |
run: | | |
if [ "${{ matrix.os }}" = "windows-latest" ]; then | |
pyinstaller --onefile cli/main.py --name "codethreat-cli.exe" --icon=ct.ico | |
else | |
pyinstaller --onefile cli/main.py --name "codethreat-cli" --icon=ct.ico | |
fi | |
shell: bash | |
- name: Archive the build output for Windows | |
if: startsWith(matrix.os, 'windows') | |
run: | | |
Compress-Archive -Path dist\codethreat-cli.exe -DestinationPath dist/codethreat-cli-${{ needs.bump_version.outputs.revision }}-${{ matrix.architecture }}-${{ matrix.os }}.zip | |
shell: pwsh | |
- name: Archive the build output for Linux and macOS | |
if: matrix.os != 'windows-latest' | |
run: | | |
tar -czvf dist/codethreat-cli-${{ needs.bump_version.outputs.revision }}-${{ matrix.architecture }}-${{ matrix.os }}.tar.gz -C dist codethreat-cli | |
shell: bash | |
- name: List files in dist directory | |
run: ls -lR . | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: codethreat-cli-${{ needs.bump_version.outputs.revision }}-${{ matrix.architecture }}-${{ matrix.os }} | |
path: | | |
dist/codethreat-cli-${{ needs.bump_version.outputs.revision }}-${{ matrix.architecture }}-${{ matrix.os }}.* | |
release-artifacts: | |
needs: [bump_version, build] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
path: dist | |
- name: List files in dist directory | |
run: ls -lR dist | |
- name: Create GitHub release | |
id: create_release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ needs.bump_version.outputs.revision }} | |
name: "Release ${{ needs.bump_version.outputs.revision }}" | |
body_path: dist/body.md | |
draft: false | |
prerelease: false | |
files: | | |
dist/codethreat-cli-${{ needs.bump_version.outputs.revision }}-arm64-macos-latest/codethreat-cli-${{ needs.bump_version.outputs.revision }}-arm64-macos-latest.tar.gz | |
dist/codethreat-cli-${{ needs.bump_version.outputs.revision }}-arm64-ubuntu-latest/codethreat-cli-${{ needs.bump_version.outputs.revision }}-arm64-ubuntu-latest.tar.gz | |
dist/codethreat-cli-${{ needs.bump_version.outputs.revision }}-arm64-windows-latest/codethreat-cli-${{ needs.bump_version.outputs.revision }}-arm64-windows-latest.zip | |
dist/codethreat-cli-${{ needs.bump_version.outputs.revision }}-x86_64-macos-latest/codethreat-cli-${{ needs.bump_version.outputs.revision }}-x86_64-macos-latest.tar.gz | |
dist/codethreat-cli-${{ needs.bump_version.outputs.revision }}-x86_64-ubuntu-latest/codethreat-cli-${{ needs.bump_version.outputs.revision }}-x86_64-ubuntu-latest.tar.gz | |
dist/codethreat-cli-${{ needs.bump_version.outputs.revision }}-x86_64-windows-latest/codethreat-cli-${{ needs.bump_version.outputs.revision }}-x86_64-windows-latest.zip | |
dist/body.md | |
env: | |
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" |