@@ -450,10 +450,15 @@ jobs:
450450 -p ${namespace} \
451451 -a ${account_id}
452452
453+
453454 Release :
454455 needs : [Deploy]
455456 runs-on : ubuntu-latest
456- if : ${{ github.event.action == 'published' || github.event.action == 'prereleased' }}
457+ if : ${{
458+ github.event.action == 'published' ||
459+ github.event.action == 'prereleased' ||
460+ (github.event_name == 'workflow_call' && inputs.release != 'none') ||
461+ github.event_name == 'workflow_dispatch'}}
457462 steps :
458463 - name : Checkout repository
459464 uses : actions/checkout@v3
@@ -484,63 +489,39 @@ jobs:
484489 [ -f "./scripts/deploy.sh" ] && echo "deploy.sh found" || echo "deploy.sh missing"
485490 [ -f "./scripts/restore_db.sh" ] && echo "restore_db.sh found" || echo "restore_db.sh missing"
486491
487- - name : Create GitHub Release
488- id : create_release
489- uses : actions/create-release@v1
492+ - name : Generate Release Tag
493+ id : generate_tag
494+ run : |
495+ if [ "${{ github.event_name }}" == "release" ]; then
496+ echo "tag_name=${{ github.ref_name }}" >> $GITHUB_OUTPUT
497+ elif [ "${{ inputs.version_tag }}" != "master" ] && [ "${{ inputs.version_tag }}" != "" ]; then
498+ echo "tag_name=${{ inputs.version_tag }}" >> $GITHUB_OUTPUT
499+ else
500+ # Generate a unique tag based on current timestamp and run number
501+ TAG_NAME="v$(date +%Y%m%d-%H%M%S)-${{ github.run_number }}"
502+ echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT
503+ fi
504+
505+ - name : Create or Update GitHub Release
506+ uses : softprops/action-gh-release@v1
490507 with :
491- tag_name : ${{ github.ref_name }}
492- release_name : Release ${{ github.ref_name }}
508+ tag_name : ${{ steps.generate_tag.outputs.tag_name }}
509+ name : Release ${{ steps.generate_tag.outputs.tag_name }}
493510 body : |
494511 This release includes the following artifacts:
495512 - build_artifacts.zip
496513 - terraform_artifacts.zip
497514 - deploy.sh
498515 - restore_db.sh
516+
517+ Generated from workflow run: ${{ github.run_number }}
518+ Commit: ${{ github.sha }}
499519 draft : false
500520 prerelease : false
501- env :
502- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
503-
504- - name : Upload Build Artifacts
505- if : ${{ hashFiles('./bin/build_artifacts.zip') != '' }}
506- uses : actions/upload-release-asset@v1
507- with :
508- upload_url : ${{ steps.create_release.outputs.upload_url }}
509- asset_path : ./bin/build_artifacts.zip
510- asset_name : build_artifacts.zip
511- asset_content_type : application/zip
512- env :
513- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
514-
515- - name : Upload Terraform Artifacts
516- if : ${{ hashFiles('./bin/terraform_artifacts.zip') != '' }}
517- uses : actions/upload-release-asset@v1
518- with :
519- upload_url : ${{ steps.create_release.outputs.upload_url }}
520- asset_path : ./bin/terraform_artifacts.zip
521- asset_name : terraform_artifacts.zip
522- asset_content_type : application/zip
523- env :
524- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
525-
526- - name : Upload Deploy Script
527- if : ${{ hashFiles('./scripts/deploy.sh') != '' }}
528- uses : actions/upload-release-asset@v1
529- with :
530- upload_url : ${{ steps.create_release.outputs.upload_url }}
531- asset_path : ./scripts/deploy.sh
532- asset_name : deploy.sh
533- asset_content_type : text/x-shellscript
534- env :
535- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
536-
537- - name : Upload Restore DB Script
538- if : ${{ hashFiles('./scripts/restore_db.sh') != '' }}
539- uses : actions/upload-release-asset@v1
540- with :
541- upload_url : ${{ steps.create_release.outputs.upload_url }}
542- asset_path : ./scripts/restore_db.sh
543- asset_name : restore_db.sh
544- asset_content_type : text/x-shellscript
521+ files : |
522+ ./bin/build_artifacts.zip
523+ ./bin/terraform_artifacts.zip
524+ ./scripts/deploy.sh
525+ ./scripts/restore_db.sh
545526 env :
546527 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments