Refactor release workflow to tag and push beta versions #55
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: Linpad application | |
on: | |
push: | |
branches: [ "Automatic-release-deb-file-in-github" ] | |
pull_request: | |
branches: [ "Automatic-release-deb-file-in-github" ] | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: read | |
attestations: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 # Updated to v3 | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v3 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install flake8 pytest | |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
- name: Lint with flake8 | |
run: | | |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | |
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | |
- name: Test with pytest | |
run: | | |
pytest test/ | |
- name: Update executable in usr/bin | |
run: | | |
cp linpad.py usr/bin/linpad | |
chmod +x usr/bin/linpad | |
- name: List project files | |
run: | | |
ls -R | |
- name: Package Application | |
run: | | |
mkdir -p output | |
cp -r ./linpad.py ./output/ | |
cp ./lin_logo.webp ./output/ | |
cp -r ./DEBIAN ./output/ | |
cp README.md ./output/ | |
cp LICENSE ./output/ | |
cp -r ./usr ./output/usr | |
- name: Create .deb Package | |
run: | | |
cd output | |
dpkg-deb --build . linpad.deb | |
- name: Upload .deb Package | |
uses: actions/upload-artifact@v3 | |
with: | |
name: linpad-deb-package | |
path: output/linpad.deb | |
- name: Attest | |
uses: actions/attest-build-provenance@v1 | |
id: attest | |
with: | |
subject-path: '${{ github.workspace }}/output' | |
- name: Tag the release version | |
id: tag_version | |
run: | | |
# Fetch the latest tag | |
TAG=$(git describe --tags --abbrev=0) | |
# Extract the version numbers | |
VERSION=${TAG//v/} | |
# Split into an array | |
IFS='.' read -r -a VERSION_ARRAY <<< "$VERSION" | |
# Increment the last digit for beta versions | |
LAST=${VERSION_ARRAY[2]} | |
NEW_LAST=$((LAST + 1)) | |
NEW_VERSION="v${VERSION_ARRAY[0]}.${VERSION_ARRAY[1]}.$NEW_LAST-beta" | |
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV | |
git tag $NEW_VERSION | |
git push origin --tags # Ensure the tag is pushed |