Skip to content

Build -> Create Release #7

Build -> Create Release

Build -> Create Release #7

---
name: Build -> Create Release
# yamllint disable rule:line-length
on:
workflow_dispatch:
inputs:
version:
description: 'The version for the release'
required: true
default: '0.0.0'
draft:
description: 'Whether the release should be a draft '
required: true
default: 'true'
jobs:
validate:
name: Validates inputs
runs-on: ubuntu-latest
permissions:
contents: read
steps:
#validates that the version is a valid semver
- name: Validate version
id: validate_version
run: |
if [[ ! ${{ inputs.version }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Invalid version: ${{ inputs.version }}"
exit 1
fi
#validates that the draft is a valid boolean
- name: Validate draft
id: validate_draft
run: |
if [[ ! ${{ inputs.draft }} =~ ^(true|false)$ ]]; then
echo "Invalid draft: ${{ inputs.draft }}"
exit 1
fi
build:
name: Build packages
needs: validate
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: macos-latest
TARGET: macos
CMD_BUILD: >
pyinstaller podshell.spec &&
pyinstaller podshell-console.spec &&
cd dist &&
zip -r9 podshell-macos *
OUT_FILE_NAME: podshell-macos.zip
- os: windows-latest
TARGET: windows
CMD_BUILD: >
pyinstaller podshell.spec &&
pyinstaller podshell-console.spec &&
cd dist &&
tar -acvf podshell-windows.zip podshell-console.exe podshell.exe
OUT_FILE_NAME: podshell-windows.zip
permissions:
contents: write
steps:
- name: Checkout
uses: actions/[email protected]
- name: Set up Python 3.11
uses: actions/[email protected]
with:
python-version: 3.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r ./requirements.txt
pip install pyinstaller
pip install Pillow
- name: Build with pyinstaller for ${{matrix.TARGET}}
run: ${{matrix.CMD_BUILD}}
- name: Archive artifacts
uses: actions/[email protected]
with:
name: ${{ matrix.OUT_FILE_NAME }}
path: dist/${{ matrix.OUT_FILE_NAME }}
if-no-files-found: error
create_release:
name: Create Release
runs-on: ubuntu-latest
needs: build
permissions:
contents: write
steps:
- name: Get current date and time
id: datetime
run: |
datetime=$(date +'%Y-%m-%dT%H-%M-%SZ')
echo "datetime=$datetime" >> $GITHUB_OUTPUT
- name: Display Run Name
run: echo ${{ steps.datetime.outputs.datetime }}
- name: Checkout
uses: actions/[email protected]
# note: this will download all artifacts to a directory for each artifact
# https://github.com/actions/download-artifact/tree/v2.1.1/#download-all-artifacts
- name: Download artifacts
uses: actions/[email protected]
with:
path: dist/
- name: Display structure of downloaded files
run: ls -R
working-directory: dist/
- name: Create release branch
run: |
git checkout -b "release/${{ inputs.version }}"
git push origin "release/${{ inputs.version }}"
- name: Create DRAFT release through github cli and upload assets
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ inputs.draft == 'true' }}
run: |
gh release create ${{ inputs.version }} --title ${{ inputs.version }} --generate-notes 'dist/podshell-macos.zip/podshell-macos.zip' 'dist/podshell-windows.zip/podshell-windows.zip' --draft
- name: Create PUBLISHED release through github cli and upload assets
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ inputs.draft == 'false' }}
run: |
gh release create ${{ inputs.version }} --title ${{ inputs.version }} --generate-notes 'dist/podshell-macos.zip/podshell-macos.zip' 'dist/podshell-windows.zip/podshell-windows.zip'