Skip to content

Bump http-proxy-middleware from 2.0.6 to 2.0.7 in the npm_and_yarn gr… #42

Bump http-proxy-middleware from 2.0.6 to 2.0.7 in the npm_and_yarn gr…

Bump http-proxy-middleware from 2.0.6 to 2.0.7 in the npm_and_yarn gr… #42

Workflow file for this run

name: Build Offline Browsable Version
on:
workflow_dispatch:
push:
branches:
- main
permissions:
contents: write
id-token: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "21"
- name: Set environment variable for hash router
run: echo "USE_HASH_ROUTER=true" >> $GITHUB_ENV
- name: Install dependencies
run: npm ci
- name: Build the offline site
run: npm run build
continue-on-error: true # sometimes it gives errors, but the page is still browsable. Will remove this when the experimental_router is stable
- name: Create a release directory
run: mkdir -p release && cp -r build/* release
- name: Get version from package.json
id: get_version
run: echo "PACKAGE_VERSION=$(jq -r '.version' package.json)" >> $GITHUB_ENV
- name: Create a versioned zip file of the offline site
run: cd release && zip -r ../docugrammar-offline-v${{ env.PACKAGE_VERSION }}.zip .
- name: Upload Release Asset
uses: actions/upload-artifact@v4
with:
name: docugrammar-offline
path: docugrammar-offline-v${{ env.PACKAGE_VERSION }}.zip
- name: Get latest tag
id: get_tag
run: |
latest_tag=$(git tag | sort -V | tail -n 1)
if [ -z "$latest_tag" ]; then
new_tag="v${{ env.PACKAGE_VERSION }}"
else
new_tag="v$(( ${latest_tag#v} + 1 ))"
fi
echo "latest_tag=$new_tag" >> $GITHUB_ENV
- name: Create tag
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git tag ${{ env.latest_tag }}
git push origin ${{ env.latest_tag }}
- name: Generate changelog
id: generate_changelog
uses: actions/github-script@v7
with:
script: |
const { data: tags } = await github.rest.repos.listTags({
owner: context.repo.owner,
repo: context.repo.repo,
per_page: 1,
});
const latestTag = tags.length > 0 ? tags[0].name : null;
if (latestTag) {
const { data: compare } = await github.rest.repos.compareCommits({
owner: context.repo.owner,
repo: context.repo.repo,
base: latestTag,
head: 'HEAD',
});
const changelog = compare.commits
.map(commit => `- ${commit.commit.message}`)
.join("\n");
const finalChangelog = changelog || 'No significant changes.';
core.setOutput('changelog', finalChangelog);
} else {
const { data: commits } = await github.rest.repos.listCommits({
owner: context.repo.owner,
repo: context.repo.repo,
per_page: 100,
sha: 'HEAD',
});
const changelog = commits
.map(commit => `- ${commit.commit.message}`)
.join("\n");
const finalChangelog = changelog || 'No significant changes.';
core.setOutput('changelog', finalChangelog);
}
- name: Create GitHub release
id: create_release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.latest_tag }}
name: v${{ env.PACKAGE_VERSION }}
body: ${{ steps.generate_changelog.outputs.changelog }}
files: docugrammar-offline-v${{ env.PACKAGE_VERSION }}.zip