Skip to content

Use better vars in workflow #23

Use better vars in workflow

Use better vars in workflow #23

Workflow file for this run

name: Release
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 }}
plugin_name: Rotor
plugin_version: 1.0.0
plugin_bundle_id: com.bbx-audio.rotor
secrets: inherit
Release:
runs-on: ubuntu-latest
needs: [ Package ]
permissions:
contents: write
id-token: write
env:
PLUGIN_NAME: Rotor
PLUGIN_VERSION: 1.0.0
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Download Artifacts
uses: actions/download-artifact@v4
- 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 "WINDOWS_ARTIFACT_NAME=$PLUGIN_NAME v$PLUGIN_VERSION (Windows)" >> $GITHUB_ENV
echo "MACOS_ARTIFACT_NAME=$PLUGIN_NAME v$PLUGIN_VERSION (macOS)" >> $GITHUB_ENV
- 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: |
gcloud storage cp "**/*.dmg" "gs://${{ secrets.GOOGLE_CLOUD_STORAGE_BUCKET }}/${{ env.STAGE }}"
- name: Prepare Body
run: |
echo "### Changelog" >> CHANGELOG.md
echo "------" >> CHANGELOG.md
- name: Draft Release
uses: softprops/action-gh-release@v2
with:
name: ${{ env.RELEASE_NAME }}
prerelease: ${{ env.STAGE != 'production' }}
draft: true
body_path: ./CHANGELOG.md
files: |
*.dmg