Skip to content

Import all env vars everywhere #73

Import all env vars everywhere

Import all env vars everywhere #73

Workflow file for this run

name: Release (CD)
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-[a-z]+'
- 'v[0-9]+.[0-9]+.[0-9]+-[a-z]+.[0-9]+'
defaults:
run:
shell: bash
jobs:
Build:
name: Build Release (${{ matrix.os }})
uses: ./.github/workflows/reusable.build.yml
strategy:
fail-fast: true
matrix:
os: [ 'macos-13' , 'windows-2022' ]
with:
os: ${{ matrix.os }}
build_type: Release
upload_artifacts: ${{ true }}
Package:
name: Package Build (${{ matrix.os }})
uses: ./.github/workflows/reusable.package.yml
needs: [ Build ]
strategy:
fail-fast: false
matrix:
include:
- name: macOS
os: macos-13
- name: Windows
os: windows-2022
with:
os: ${{ matrix.os }}
secrets: inherit
Release:
runs-on: ubuntu-latest
needs: [ Package ]
permissions:
contents: write
id-token: write
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Download Artifacts
uses: actions/download-artifact@v4
- name: Import Environment Variables
run: |
source plugin.env
echo "COMPANY_NAME=$COMPANY_NAME" >> $GITHUB_ENV
echo "COMPANY_WEBSITE=$COMPANY_WEBSITE" >> $GITHUB_ENV
echo "PLUGIN_NAME=$PLUGIN_NAME" >> $GITHUB_ENV
echo "PLUGIN_CODE=$PLUGIN_CODE" >> $GITHUB_ENV
echo "PLUGIN_VERSION=$PLUGIN_VERSION" >> $GITHUB_ENV
echo "PLUGIN_BUNDLE_ID=$PLUGIN_BUNDLE_ID" >> $GITHUB_ENV
- name: Set Environment Variables
run: |
VERSION=${GITHUB_REF#refs/tags/v}
STAGE_INFO=$(echo "$VERSION" | perl -0777 -pe 's/^([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([a-z]+)(?:\.([0-9]+))?)?$/\1 \2 \3 \4 \5/')
MAJOR=$(echo "$STAGE_INFO" | awk '{print $1}')
MINOR=$(echo "$STAGE_INFO" | awk '{print $2}')
PATCH=$(echo "$STAGE_INFO" | awk '{print $3}')
STAGE=$(echo "$STAGE_INFO" | awk '{print $4}')
STAGE_VERSION=$(echo "$STAGE_INFO" | awk '{print $5}')
if [ -z "$STAGE" ]; then
RELEASE_NAME="$PLUGIN_NAME v$MAJOR.$MINOR.$PATCH"
STAGE=production
else
if [ -z "$STAGE_VERSION" ]; then
STAGE_VERSION=1
fi
RELEASE_NAME="$PLUGIN_NAME v$MAJOR.$MINOR.$PATCH-$STAGE.$STAGE_VERSION"
fi
echo "VERSION=$MAJOR.$MINOR.$PATCH" >> $GITHUB_ENV
echo "STAGE=$STAGE" >> $GITHUB_ENV
echo "STAGE_VERSION=$STAGE_VERSION" >> $GITHUB_ENV
echo "RELEASE_NAME=$RELEASE_NAME" >> $GITHUB_ENV
echo "INSTALLER_ARTIFACT_NAME=$PLUGIN_NAME-$PLUGIN_VERSION" >> $GITHUB_ENV
echo "INSTALLER_DELIVERABLE_STORAGE_PATH=plugins/$PLUGIN_NAME/$STAGE/$PLUGIN_VERSION" >> $GITHUB_ENV
echo "INSTALLER_DELIVERABLE_NAME=$PLUGIN_NAME $PLUGIN_VERSION Installer" >> $GITHUB_ENV
- name: Check Tag & Version
run: |
if [[ $PLUGIN_VERSION != *"$VERSION"* ]]; then
echo "The plugin version specified in this workflow and tag-derived version do not match. Exiting."
exit 1
fi
if [[ $STAGE != "production" ]] && [[ $PLUGIN_VERSION != *"$STAGE"* ]]; then
echo "The plugin version stage specified in this workflow and tag-derived version stage do not match. Exiting."
exit 1
fi
- name: Authenticate Google Cloud
uses: google-github-actions/auth@v2
with:
project_id: ${{ secrets.GOOGLE_CLOUD_PROJECT_ID }}
service_account: ${{ secrets.GOOGLE_CLOUD_SERVICE_ACCOUNT }}
credentials_json: ${{ secrets.GOOGLE_CLOUD_AUTH_JSON }}
- name: Setup Google Cloud
uses: google-github-actions/setup-gcloud@v2
with:
project_id: ${{ secrets.GOOGLE_CLOUD_PROJECT_ID }}
- name: Upload to Cloud Storage
run: |
mv "${{ env.INSTALLER_ARTIFACT_NAME }}-macOS/${{ env.INSTALLER_ARTIFACT_NAME }}.dmg" "${{ env.INSTALLER_DELIVERABLE_NAME }}.dmg"
mv "${{ env.INSTALLER_ARTIFACT_NAME }}-Windows/${{ env.INSTALLER_ARTIFACT_NAME }}.exe" "${{ env.INSTALLER_DELIVERABLE_NAME }}.exe"
gcloud storage cp "*.dmg" "gs://${{ secrets.GOOGLE_CLOUD_STORAGE_BUCKET }}/${{ env.INSTALLER_DELIVERABLE_STORAGE_PATH }}/${{ env.INSTALLER_DELIVERABLE_NAME }}.dmg"
gcloud storage cp "*.exe" "gs://${{ secrets.GOOGLE_CLOUD_STORAGE_BUCKET }}/${{ env.INSTALLER_DELIVERABLE_STORAGE_PATH }}/${{ env.INSTALLER_DELIVERABLE_NAME }}.exe"
- name: Prepare Body
run: |
echo "### Overview" >> RELEASE.md
echo "" >> RELEASE.md
if [[ $STAGE == "production" ]]; then
echo "New $PLUGIN_NAME release! 🚀" >> RELEASE.md
else
echo "New $PLUGIN_NAME $STAGE (no. $STAGE_VERSION) release! 🚀" >> RELEASE.md
fi
echo "" >> RELEASE.md
echo "Download the plugin installers below and have fun!" >> RELEASE.md
echo "" >> RELEASE.md
echo "------" >> RELEASE.md
echo "" >> RELEASE.md
echo "### Changelog" >> RELEASE.md
echo "" >> RELEASE.md
echo "**Added**:" >> RELEASE.md
echo "- ..." >> RELEASE.md
echo "" >> RELEASE.md
echo "**Changed**:" >> RELEASE.md
echo "- ..." >> RELEASE.md
echo "" >> RELEASE.md
echo "**Removed**:" >> RELEASE.md
echo "- ..." >> RELEASE.md
echo "" >> RELEASE.md
echo "**Full Changelog**: https://github.com/blackboxaudio/rotor/compare/vX.Y.Z...v$PLUGIN_VERSION" >> RELEASE.md
- name: Draft Release
uses: softprops/action-gh-release@v2
with:
name: ${{ env.RELEASE_NAME }}
prerelease: ${{ env.STAGE != 'production' }}
draft: true
body_path: ./RELEASE.md
files: |
**/*.dmg
**/*.exe