Skip to content

πŸ“¦ Create Release #2

πŸ“¦ Create Release

πŸ“¦ Create Release #2

name: πŸ“¦ Create Release
on:
workflow_dispatch:
jobs:
create-release:
name: πŸ†• Create Release
runs-on: ubuntu-latest
steps:
- name: 🌍 Set environment
id: set-environment
run: |
if [[ "${{ github.ref_name }}" == "release-candidate/"* ]]; then
echo "ENVIRONMENT=Release" >> $GITHUB_ENV
else
echo "Release needs to be created from release-candidate branches"
exit 1
fi
- uses: actions/checkout@v3.2.0
with:
fetch-depth: "0"
- name: ❔ Extract project version
shell: bash
run: |
VERSION=$( echo ${{ github.ref_name }} | sed -e "s/release.*\///g")
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: πŸͺ£ Init Git
shell: bash
run: |
git config --global user.email "svc@users.noreply.github.com"
git config --global user.name "svc"
- name: βš™οΈ Set release branch parameters
id: get-release-branch
run: |
echo "BRANCH_RELEASE=release/${{ env.VERSION }}" >> $GITHUB_ENV
echo "RELEASE_CANDIDATE_SHA=$(git rev-parse ${{ github.ref_name }})" >> $GITHUB_ENV
- name: πŸ†• Create Branch release
uses: peterjgrainger/action-create-branch@v2.4.0
env:
GITHUB_TOKEN: ${{ secrets.SVC_GITHUB_TOKEN }}
with:
branch: ${{ env.BRANCH_RELEASE }}
sha: "${{ env.RELEASE_CANDIDATE_SHA }}"
- uses: actions/checkout@v3.2.0
with:
token: ${{ secrets.SVC_GITHUB_TOKEN }}
ref: ${{ env.BRANCH_RELEASE }}
clean: true
fetch-depth: "0"
- name: βŒ› Wait for build to be triggered
shell: bash
run: sleep 30
- name: βŒ› Wait for build to complete
uses: ./.github/actions/utils/wait-job
with:
BRANCH: ${{ env.BRANCH_RELEASE }}
GITHUB_TOKEN: ${{ secrets.SVC_GITHUB_TOKEN }}
- name: πŸ—‘οΈ Delete Release Candidate branch
continue-on-error: true
uses: dawidd6/action-delete-branch@v3.1.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branches: "release-candidate/${{ env.VERSION }}"