GitHub reusable Workflows definition used to automate publishing releases in repositories.
Retrieve version from README.md in repository root, looking for phrase:
##### version:
Everything in same line after : will be considered as desired version
-
Check Version:
- Retrieves version from
README.md - Checks if tag is not referenced to Full Release.
If it is, than job will fail to block
PRfrom merging.
- Retrieves version from
-
Create Tag:
- Creates new tag if the one with retrieved version does not exist.
- If tag for this version exists, then it updates tag reference
-
Create Release:
- Takes
pre_releaseflag as an input param. - Creates new Release if the one with retrieved version does not exist.
- If Release exists updates it.
- Takes
-
Upload Assets:
- Takes
files_to_archiveandarchive_nameas an input param.files_to_archiveis aspaceseparated list of paths which should be included in archive. - Deletes existing asset
- Creates new archive with files from
files_to_archivelist. - Uploads new archive to the created release.
- Takes
-
Check Version:
- Retrieves version from
README.md - Checks if tag is not referenced to Full Release. If it is, than job will fail to block any modifications on Full Release.
- Retrieves version from
-
Remove Release:
- Removes release if exists.
Example Workflow to place in application repository to trigger Releases creation on pull requests.
It includes the deployment to dev environment using workflows from Actions_Deployments.
When PR is opened, pre-release is created on each push. If the current version is overlapping with existing Full Release version, then Workflow with fail to block merge option (as a result pre-release will not be created).
On PR merge existing pre-release is updated with new assets and references and marked as Full Release.
If PR is closed without merge, than existing pre-release and version tag is removed.
Warning
If PR containing conflicts is being closed, auto-cleanup will not work. No GitHub Actions can be started on PR with conflicts (current GitHub Actions limitation)
name: CI/CD
run-name: CI/CD ${{github.event.pull_request.title}}
on:
pull_request:
types: [ opened, synchronize, closed ]
permissions:
contents: write
jobs:
Pre:
if: github.event.pull_request.merged == false && (github.event.action == 'opened' || github.event.action == 'synchronize')
uses: HornaHomeLab/Actions_Releases/.github/workflows/Process_create_release.yml@main
with:
pre_release: true
archive_name: "test"
Full:
if: github.event.pull_request.merged == true && github.event.action == 'closed'
uses: HornaHomeLab/Actions_Releases/.github/workflows/Process_create_release.yml@main
with:
pre_release: false
archive_name: "test"
latest: true
Deploy:
needs: Full
uses: HornaHomeLab/Actions_Deployments/.github/workflows/Run_docker_compose.yml@main
with:
environment: "development"
version: ${{ needs.Full.outputs.released_version }}
secrets: inherit
Remove:
if: github.event.pull_request.merged == false && github.event.action == 'closed'
uses: HornaHomeLab/Actions_Releases/.github/workflows/Process_remove_release.yml@main