From 382a0e8847d015bdb9beee04160b10419703f119 Mon Sep 17 00:00:00 2001 From: Harsh Upadhyay <49197635+harshau007@users.noreply.github.com> Date: Mon, 18 Dec 2023 22:18:14 +0530 Subject: [PATCH] Update release.yml --- .github/workflows/release.yml | 66 ++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 25 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cd70d96..bde7192 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,6 +1,9 @@ name: Release on: + push: + branches: + - main workflow_dispatch: jobs: @@ -9,45 +12,58 @@ jobs: permissions: contents: write + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Set current date as environment variable run: echo "DATE=`date +'%Y.%m.%d'`" >>$GITHUB_ENV - - name: Building TCET Linux Welcome Tar file + - name: Building TCET Linux installer-config Tar file run: | - ls -la cd .. - ls -la + touch tcet-linux-installer-config.tar.gz tar -czf tcet-linux-installer-config.tar.gz tcet-linux-installer-config/ touch checksum sha256sum tcet-linux-installer-config.tar.gz > checksum mv checksum tcet-linux-installer-config/ mv tcet-linux-installer-config.tar.gz tcet-linux-installer-config/ - ls -la - - name: Delete Previous Latest release - uses: dev-drprasad/delete-tag-and-release@v1.0 - with: - tag_name: latest - github_token: ${{ secrets.PAT_TOKEN }} - delete_release: true + - name: Checking if release with date tag exist + run: | + tag=${{ env.DATE }} + if gh release view $tag; then + echo "RELEASE_EXISTS=true" >> $GITHUB_ENV + else + echo "RELEASE_EXISTS=false" >> $GITHUB_ENV + fi - - name: Release Tar File with latest - uses: ncipollo/release-action@v1 - with: - artifacts: "*.tar.gz,checksum" - generateReleaseNotes: false - name: "TCET-Linux Installer Config" - tag: latest - + - name: Checking if release with latest tag exist + run: | + tag=latest + if gh release view $tag; then + echo "LATEST_RELEASE_EXISTS=true" >> $GITHUB_ENV + else + echo "LATEST_RELEASE_EXISTS=false" >> $GITHUB_ENV + fi + + - name: Deleting Dated release + if: env.RELEASE_EXISTS == 'true' + run: | + gh release delete ${{ env.DATE }} + + - name: Delete Previous Latest release + if: env.LATEST_RELEASE_EXISTS == 'true' + run: | + gh release delete latest - name: Release Tar File - uses: ncipollo/release-action@v1 - with: - artifacts: "*.tar.gz,checksum" - generateReleaseNotes: false - name: "TCET-Linux Installer Config" - tag: ${{ env.DATE }} + run: | + gh release create ${{ env.DATE }} *tar.gz checksum --title "TCET-Linux installer-config" + - name: Release Tar File with latest + run: | + gh release create latest *tar.gz checksum --latest --title "TCET-Linux installer-config"