Skip to content

Commit

Permalink
Created release.yml and update pylint.yml
Browse files Browse the repository at this point in the history
Now pylint runs for all python scripts inside the repo and release action is created to create a release automatically everytime we do a PR successfully
dmtzs committed Dec 19, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent abc51a3 commit ac6df26
Showing 2 changed files with 59 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -45,4 +45,4 @@ jobs:
- name: Analysing the code with pylint
if: env.CHANGED != '0'
run: |
pylint $(git ls-files './src*.py') --rcfile=.github/config/.pylintrc ./
pylint $(git ls-files './*.py') --rcfile=.github/config/.pylintrc ./
58 changes: 58 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Release Workflow

on:
pull_request:
types: [closed]

jobs:
release:
if: github.event_name == 'pull_request' && github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'master'
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GH_API_TOKEN }}
VERSION: ""
COMMIT_MESSAGE: ""
RELEASE_ID: ""
steps:
- name: Checkout code
uses: actions/checkout@v4

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

# - name: Upload release artifact
# uses: actions/upload-artifact@v3
# with:
# name: cert.pem
# path: /home/runner/work/CameraRaspPython/CameraRaspPython/X509-cert-3470865803141646530.pem

- name: Set commit message and version as env variables
run: |
echo "COMMIT_MESSAGE<<EOF" >> $GITHUB_ENV
git log --format='%B' -n 1 >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
echo "VERSION=$(jq -r .version config.json)" >> $GITHUB_ENV
- name: Install gh
run: |
type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y)
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt update
sudo apt install gh -y
- name: Create release
run: |
gh release create v${{ env.VERSION }} \
--title "Release v${{ env.VERSION }}" \
--notes "${{ env.COMMIT_MESSAGE }}" \
--repo ${{ github.repository }} \
--target ${{ github.sha }}
RELEASE_ID=$(gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/releases/tags/v${{ env.VERSION }} | jq '.id')
echo "RELEASE_ID=$RELEASE_ID" >> $GITHUB_ENV

0 comments on commit ac6df26

Please sign in to comment.