Skip to content

Release

Release #3

Workflow file for this run

name: Release
permissions:
contents: write
on:
workflow_run:
workflows: ["Build"]
types: [completed]
branches: [release]
workflow_dispatch:
jobs:
Build-and-Release:
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Print branch and commit info
env:
REF_NAME: ${{ github.ref_name }}
HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }}
DEFAULT_SHA: ${{ github.sha }}
EVENT_SHA: ${{ github.event.workflow_run.head_commit.id }}
EVENT_MSG: ${{ github.event.workflow_run.head_commit.message }}
run: |
BRANCH="${HEAD_BRANCH:-$REF_NAME}"
echo "branch=${BRANCH:-unset}"
echo "sha=${EVENT_SHA:-$DEFAULT_SHA}"
echo "msg=${EVENT_MSG:-event payload missing}"
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ github.event.workflow_run.head_sha }}
- name: Print commit info from repo
run: |
git show -1 --pretty=format:'Commit SHA: %H%nCommit message: %B'
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Run lint
run: npm run lint
- name: Check formatting
run: npm run format-check
- name: Install jq
run: sudo apt-get update && sudo apt-get install -y jq
- name: Get version
id: version
run: echo "version=$(jq -r .version package.json)" >> $GITHUB_OUTPUT
- name: Print version
run: |
echo "Version: '${{ steps.version.outputs.version }}'"
- name: Build project for Current Dir
run: npm run build --qPublicBasePath=app/current/excel
- name: Release to current dir
run: |
# Update current
rm -rf "docs/app/current/excel"
mkdir -p "docs/app/current/excel"
cp -r dist/spa/* "docs/app/current/excel/"
- name: Prepare Manifest for the Current dir
continue-on-error: true
run: |
# Copy manifest file
if [ ! -f "ExpLens.Excel-AddIn.Manifest.Local.xml" ]; then
echo "Error: Source manifest file not found: ExpLens.Excel-AddIn.Manifest.Local.xml"
exit 1
fi
cp "ExpLens.Excel-AddIn.Manifest.Local.xml" "docs/app/current/excel/ExpLens.Excel-AddIn.Manifest.xml"
if [ ! -f "docs/app/current/excel/ExpLens.Excel-AddIn.Manifest.xml" ]; then
echo "Error: Failed to copy manifest file to 'docs/app/current/excel/ExpLens.Excel-AddIn.Manifest.xml'"
exit 1
fi
# Replace localhost URL with production URL
sed -i 's|http://localhost:9000|https://explens.app|g' "docs/app/current/excel/ExpLens.Excel-AddIn.Manifest.xml"
echo "Manifest for 'current' deployment prepared successfully"
- name: Upload Manifest Artifact for the Current dir
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: ExpLens.Excel-AddIn.Manifest.xml
path: docs/app/current/excel/ExpLens.Excel-AddIn.Manifest.xml
retention-days: 90
compression-level: 0
- name: Build project for Version Dir
run: |
VERSION=${{ steps.version.outputs.version }}
npm run build --qPublicBasePath=app/$VERSION/excel
- name: Release to Version dir
run: |
VERSION=${{ steps.version.outputs.version }}
# Create version directory
if [ -d "docs/app/$VERSION" ]; then
rm -rf "docs/app/$VERSION"
fi
mkdir -p "docs/app/$VERSION/excel"
# Copy dist/spa to docs/app/version/excel
cp -r dist/spa/* "docs/app/$VERSION/excel/"
- name: Prepare Manifest for the Version dir
continue-on-error: true
run: |
VERSION=${{ steps.version.outputs.version }}
# Copy manifest file
if [ ! -f "ExpLens.Excel-AddIn.Manifest.Local.xml" ]; then
echo "Error: Source manifest file not found: ExpLens.Excel-AddIn.Manifest.Local.xml"
exit 1
fi
cp "ExpLens.Excel-AddIn.Manifest.Local.xml" "docs/app/$VERSION/excel/ExpLens.Excel-AddIn.Manifest.v_$VERSION.xml"
if [ ! -f "docs/app/$VERSION/excel/ExpLens.Excel-AddIn.Manifest.v_$VERSION.xml" ]; then
echo "Error: Failed to copy manifest file to 'docs/app/$VERSION/excel/ExpLens.Excel-AddIn.Manifest.v_$VERSION.xml'"
exit 1
fi
# Replace localhost URL with production URL
sed -i 's|http://localhost:9000|https://explens.app|g' "docs/app/$VERSION/excel/ExpLens.Excel-AddIn.Manifest.v_$VERSION.xml"
# Replace 'current' path with version-specific path
sed -i "s|app/current/|app/$VERSION/|g" "docs/app/$VERSION/excel/ExpLens.Excel-AddIn.Manifest.v_$VERSION.xml"
echo "Manifest for 'version' deployment ($VERSION) prepared successfully"
- name: Upload Manifest Artifact for the Version dir
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: ExpLens.Excel-AddIn.Manifest.v_${{steps.version.outputs.version}}.xml
path: docs/app/${{steps.version.outputs.version}}/excel/ExpLens.Excel-AddIn.Manifest.v_${{steps.version.outputs.version}}.xml
retention-days: 90
compression-level: 0
- name: Commit and push changes
env:
PUSH_BRANCH: ${{ github.event.workflow_run.head_branch || github.ref_name }}
run: |
if [ -z "${PUSH_BRANCH}" ]; then
echo "Cannot determine push target branch."
exit 1
fi
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add docs/app/
if git diff --staged --quiet; then
echo "No changes to commit"
else
git commit -m "Release Single Page App files to GitHub pages (ver: ${{ steps.version.outputs.version }})"
echo "Pushing to branch '${PUSH_BRANCH}'"
git push origin HEAD:"${PUSH_BRANCH}"
fi