Skip to content

Commit

Permalink
use centralized workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Odizinne committed Aug 7, 2024
1 parent 7ae65b0 commit f802c64
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 121 deletions.
91 changes: 1 addition & 90 deletions .github/workflows/build-and-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,93 +5,4 @@ on:

jobs:
build:
runs-on: windows-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12.4'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Build executable
run: python src/setup.py build

- name: Zip binaries folder
run: |
$zipFile = "build/${{ github.event.repository.name }}.zip"
$folder = "build/${{ github.event.repository.name }}"
Compress-Archive -Path $folder -DestinationPath $zipFile
shell: pwsh

- name: Upload artifact zip
uses: actions/upload-artifact@v4
with:
name: ${{ github.event.repository.name }}
path: build/${{ github.event.repository.name }}.zip

release:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Download artifact zip
uses: actions/download-artifact@v4
with:
name: ${{ github.event.repository.name }}

- name: Bump version and create release
id: bump_release
run: |
git fetch --tags
# Determine the latest major version tag
LAST_MAJOR_TAG=$(git tag --list 'v*.*.*' | sed -E 's/^v?([0-9]+)\..*/\1/' | sort -nr | head -n 1)
# Increment the major version number
if [ -z "$LAST_MAJOR_TAG" ]; then
NEW_TAG="v1"
else
NEW_TAG="v$(($LAST_MAJOR_TAG + 1))"
fi
# Check if the tag already exists
if git rev-parse "$NEW_TAG" >/dev/null 2>&1; then
echo "Tag '$NEW_TAG' already exists. Incrementing to next major version."
LAST_MAJOR_TAG=$(git tag --list 'v*' | sed -E 's/^v?([0-9]+).*/\1/' | sort -nr | head -n 1)
NEW_TAG="v$(($LAST_MAJOR_TAG + 1))"
fi
echo "New tag is $NEW_TAG"
git tag $NEW_TAG
git push origin $NEW_TAG
echo "new_tag=$NEW_TAG" >> $GITHUB_ENV
- name: Create GitHub release
id: create_release
uses: actions/create-release@v1
with:
tag_name: ${{ env.new_tag }}
release_name: ${{ env.new_tag }}
body: ""
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload release assets
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ github.event.repository.name }}.zip
asset_name: ${{ github.event.repository.name }}.zip
asset_content_type: application/zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: odizinne/shared-workflows/.github/workflows/build-and-release.yml@main
32 changes: 1 addition & 31 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,4 @@ on:

jobs:
build:
runs-on: windows-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12.4'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Build executable
run: python src/setup.py build

- name: Zip binaries folder
run: |
$zipFile = "build/${{ github.event.repository.name }}.zip"
$folder = "build/${{ github.event.repository.name }}"
Compress-Archive -Path $folder -DestinationPath $zipFile
shell: pwsh

- name: Upload artifact zip
uses: actions/upload-artifact@v4
with:
name: ${{ github.event.repository.name }}
path: build/${{ github.event.repository.name }}.zip
uses: odizinne/shared-workflows/.github/workflows/build.yml@main

0 comments on commit f802c64

Please sign in to comment.