Skip to content

Refactor release workflow to use actions/checkout@v2 and handle the c… #57

Refactor release workflow to use actions/checkout@v2 and handle the c…

Refactor release workflow to use actions/checkout@v2 and handle the c… #57

Workflow file for this run

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@v2
- 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, if none found, start with v0.0.0
TAG=$(git tag -l | tail -n 1)
if [ -z "$TAG" ]; then
TAG="v0.0.0"
fi
# 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 $NEW_VERSION