From f4e5f4b47eb7139560039d4a9adf7767bff5d679 Mon Sep 17 00:00:00 2001 From: Alex Morais Date: Thu, 15 Jun 2023 21:21:06 -0600 Subject: [PATCH 1/2] Create better names for the build artifacts --- .github/workflows/bot.yml | 2 +- .github/workflows/build-windows.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/bot.yml b/.github/workflows/bot.yml index e53596f..4ec59bd 100644 --- a/.github/workflows/bot.yml +++ b/.github/workflows/bot.yml @@ -7,7 +7,7 @@ on: branches: [ main ] jobs: - build: + verify: runs-on: ubuntu-latest diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index 895e7c0..a87dbbe 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -7,7 +7,7 @@ on: branches: [ main ] jobs: - build: + build-windows: runs-on: windows-latest From e9af0f8a324974248ea9c62d4b0fe340a59a5b7e Mon Sep 17 00:00:00 2001 From: Alex Morais Date: Thu, 15 Jun 2023 21:58:49 -0600 Subject: [PATCH 2/2] Update CI/CD Pipeline and Add Release Mechanism - Updated the build-windows.yml to trigger only on push to tags starting with 'v' rather than on push or pull request to main. - Removed shell: bash from the Install dependencies step. - Replaced the Upload artifact step with a Create Release and Upload Release Asset steps to automatically create a new GitHub release and upload the built .exe file to it whenever a new tag is pushed. - Added an xmake.lua file with a new rule for automating the process of creating and pushing a new git tag with a bumped patch version for triggering the release. --- .github/workflows/build-windows.yml | 30 ++++++++++++++++++++--------- xmake.lua | 20 +++++++++++++++++++ 2 files changed, 41 insertions(+), 9 deletions(-) create mode 100644 xmake.lua diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index a87dbbe..c20a873 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -2,12 +2,11 @@ name: Build Windows executable on: push: - branches: [ main ] - pull_request: - branches: [ main ] + tags: + - 'v*' jobs: - build-windows: + build: runs-on: windows-latest @@ -23,7 +22,6 @@ jobs: run: | python -m pip install --upgrade pip if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - shell: bash - name: Install PyInstaller run: | @@ -33,8 +31,22 @@ jobs: run: | pyinstaller --onefile bot.py - - name: Upload artifact - uses: actions/upload-artifact@v2 + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - name: windows-executable - path: dist/* + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + + - name: Upload Release Asset + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./dist/bot.exe + asset_name: bot.exe + asset_content_type: application/octet-stream diff --git a/xmake.lua b/xmake.lua new file mode 100644 index 0000000..872d947 --- /dev/null +++ b/xmake.lua @@ -0,0 +1,20 @@ +rule("release") + on_run(function (target) + import("core.base.semver") + + -- Get the last git tag + local last_tag = os.iorun("git describe --tags `git rev-list --tags --max-count=1`") + + -- Bump the patch version + local version = semver.new(last_tag:match("^v(.*)")) + version:inc("patch") + + -- Create a new git tag and push it + os.exec("git tag -a v" .. tostring(version) .. " -m \"Release version v" .. tostring(version) .. "\"") + os.exec("git push origin v" .. tostring(version)) + end) + set_menu { + usage = "xmake release", + description = "create a new release", + options = {}, + }