Skip to content

Master Release

Master Release #7

name: Master Release
run-name: "Master Release"
on:
push:
branches:
- 'master'
jobs:
determine-if-deploy:
runs-on: ubuntu-latest
outputs:
deploy: ${{ steps.tag_exists.outputs.exists == 'false' }}
version: ${{ steps.latest_version.outputs.version }}
steps:
- uses: actions/checkout@v3
- uses: actions/[email protected]
with:
python-version: "3.11"
- name: Install Changelogger
run: pip install changelogged==0.11.3
- name: Get Latest Version
id: latest_version
run: |
VERSION=$(changelogger versions --latest)
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- uses: mukunku/[email protected]
id: tag_exists
with:
tag: ${{ steps.latest_version.outputs.version }}
get-changelog-contents:
runs-on: ubuntu-latest
outputs:
changelog: ${{ steps.changelog.outputs.content }}
needs: determine-if-deploy
if: needs.determine-if-deploy.outputs.deploy == 'true'
steps:
- uses: actions/checkout@v3
- uses: actions/[email protected]
with:
python-version: "3.11"
- name: Install Changelogger
run: pip install changelogged==0.11.3
- name: Get Changelog Contents
id: changelog
run: |
DELIMITER=$(openssl rand -base64 12)
VERSION=${{ needs.determine-if-deploy.outputs.version }}
# Need to capture multiline output in env to preserve newlines
echo "content<<${DELIMITER}" >> $GITHUB_OUTPUT
# Add changelog content to the env for release notes
changelogger notes $VERSION --no-pretty >> $GITHUB_OUTPUT
echo ${DELIMITER} >> $GITHUB_OUTPUT
build-zip-archives:
runs-on: ubuntu-latest
needs: determine-if-deploy
if: needs.determine-if-deploy.outputs.deploy == 'true'
strategy:
matrix:
version: [klaviyoSG, klaviyoSFRA]
env:
ZIP_FILE_NAME: ${{ matrix.version }}-${{ needs.determine-if-deploy.outputs.version }}.zip
steps:
- uses: actions/checkout@v3
- name: Create ${{ matrix.version }} Directory
# Create version specific directory for archive release
run: |
mkdir ${{ matrix.version }}
while read file; do sudo mv "$file" ${{ matrix.version }}; done < .distinclude
- name: Remove SiteGenesis cartridge and example controllers for SFRA version
if: matrix.version == 'klaviyoSFRA'
run: |
rm -r ${{ matrix.version }}/_sitegen ${{ matrix.version }}/cartridges/int_klaviyo
- name: Remove SFRA cartridge for SiteGenesis version
if: matrix.version == 'klaviyoSG'
run: |
rm -r ${{ matrix.version }}/cartridges/int_klaviyo_sfra
- name: Archive Release
uses: thedoctor0/[email protected]
with:
type: 'zip'
filename: '${{ env.ZIP_FILE_NAME }}'
path: '${{ matrix.version }}'
- name: Upload zip for tag-and-release job
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.version }}
path: ${{ env.ZIP_FILE_NAME }}
github-tag-and-release:
runs-on: ubuntu-latest
needs: [determine-if-deploy, build-zip-archives, get-changelog-contents]
if: needs.determine-if-deploy.outputs.deploy == 'true'
steps:
- name: Download zips for tag and release
uses: actions/download-artifact@v3
- name: Create GitHub Tag & Release
uses: ncipollo/release-action@v1
with:
tag: ${{ needs.determine-if-deploy.outputs.version }}
commit: ${{ github.sha }}
name: Release ${{ needs.determine-if-deploy.outputs.version }}
body: ${{ needs.get-changelog-contents.outputs.changelog }}
artifacts: 'klaviyoSG/klaviyoSG-${{ needs.determine-if-deploy.outputs.version }}.zip,klaviyoSFRA/klaviyoSFRA-${{ needs.determine-if-deploy.outputs.version }}.zip'
- name: Send PagerDuty alert on failure
if: ${{ failure() }}
uses: award28/[email protected]
with:
pagerduty-integration-key: '${{ secrets.PAGERDUTY_INTEGRATION_KEY }}'
pagerduty-dedup-key: sfcc_cd