Skip to content

Update create_release.yml #593

Update create_release.yml

Update create_release.yml #593

name: Check and Create Release
on:
push:
branches:
- main
workflow_dispatch:
jobs:
check-release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '22'
- name: Install dependencies (debug + retry + more memory/disk)
env:

Check failure on line 22 in .github/workflows/create_release.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/create_release.yml

Invalid workflow file

You have an error in your yaml syntax on line 22
NODE_OPTIONS: --max-old-space-size=6144
run: |
df -h
free -h
npm config set loglevel silly
npm install --foreground-scripts --no-audit || \
(sleep 5 && npm install --foreground-scripts --no-audit --prefer-offline)
- name: Get package.json version
id: get_version
run: echo "PACKAGE_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
- name: Get latest release version
id: get_release
run: |
curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r '.tag_name' > latest_release.txt
- name: Compare versions
id: compare_versions
run: |
if [ "$(cat latest_release.txt)" != "$PACKAGE_VERSION" ]; then
echo "Version mismatch"
echo "create_release=true" >> $GITHUB_ENV
else
echo "Version matches"
echo "create_release=false" >> $GITHUB_ENV
fi
- name: Create new release
if: env.create_release == 'true'
run: |
CURRENT_DATE=$(TZ='Asia/Shanghai' date +'%Y-%m-%d %H:%M')
sed -i "s/\$PACKAGE_VERSION/$PACKAGE_VERSION/g" CHANGELOG.md
sed -i "s/\$CURRENT_DATE/$CURRENT_DATE/g" CHANGELOG.md
gh release create "$PACKAGE_VERSION" \
--generate-notes \
-t "$PACKAGE_VERSION" \
-n "$(cat CHANGELOG.md)
---
使用方法:
| 浏览器 | 安装链接 | 备注 |
| ------------------------------- | --------------------------------------------------------------------------------------------- | -------- |
| **Chrome / Edge / Arc / Brave** | [Chrome Web Store](https://chromewebstore.google.com/detail/fbgblmjbeebanackldpbmpacppflgmlj) | 推荐 |
| **Firefox** | [Firefox Addons](https://addons.mozilla.org/zh-CN/firefox/addon/linux_do-scripts/) | 推荐 |
| **国内用户** | [Crx 商店](https://www.crxsoso.com/webstore/detail/fbgblmjbeebanackldpbmpacppflgmlj) | 无需翻墙 |
发布于:$CURRENT_DATE"
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}