Skip to content

Commit

Permalink
Refactor release workflow to use actions/checkout@v2 and handle the c…
Browse files Browse the repository at this point in the history
…ase when no tags are found
  • Loading branch information
maizied.majumder committed Oct 24, 2024
1 parent 0581d5d commit d7f058f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 33 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
id-token: write
contents: read
attestations: write

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v2

- name: Set up Python 3.10
uses: actions/setup-python@v3
Expand Down Expand Up @@ -80,8 +80,11 @@ jobs:
- name: Tag the release version
id: tag_version
run: |
# Fetch the latest tag
TAG=$(git describe --tags --abbrev=0)
# 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
Expand All @@ -92,4 +95,4 @@ jobs:
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 # Trigger the release.yml by pushing the tag
git push origin $NEW_VERSION
57 changes: 29 additions & 28 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
name: Automation to Make Releases

on:
push:
tags:
- 'v*.*.*-beta' # Trigger on the tag created from python-app.yml
push:
branches:
- "Automatic-release-deb-file-in-github"
tags:
- 'v*.*.*-beta'

jobs:
create_release:
runs-on: ubuntu-latest
create_release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Download .deb package
uses: actions/download-artifact@v3
with:
name: linpad-deb-package

- name: Download .deb package
uses: actions/download-artifact@v3
with:
name: linpad-deb-package
- name: Get current version
id: get_version
run: |
TAG=$(git describe --tags --abbrev=0)
VERSION=${TAG//v/}
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Get current version
id: get_version
run: |
TAG=$(git describe --tags --abbrev=0)
VERSION=${TAG//v/}
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.VERSION }}
name: ${{ env.VERSION }}
body: "Release of Linpad application version ${{ env.VERSION }}"
files: output/linpad.deb
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.VERSION }}
name: ${{ env.VERSION }}
body: "Release of Linpad application version ${{ env.VERSION }}"
files: linpad.deb # Adjusted the path to the downloaded artifact
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit d7f058f

Please sign in to comment.