From fafb9f322828d0b2573aa37ac52aa8a385d64578 Mon Sep 17 00:00:00 2001 From: Azalea Gui Date: Thu, 16 Feb 2023 19:27:32 -0500 Subject: [PATCH] [+] Release action --- .github/workflows/nightly.yml | 63 +++++++++++++++++++++++++++++++++++ .npmignore | 1 + package.json | 3 +- 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/nightly.yml create mode 100644 .npmignore diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml new file mode 100644 index 0000000..65d1016 --- /dev/null +++ b/.github/workflows/nightly.yml @@ -0,0 +1,63 @@ +# Build script credit to https://github.com/OpenIntelWireless/itlwm/blob/master/.github/workflows/main.yml +name: Nightly Build + +on: + push: + branches: main + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: '5' + + - uses: actions/setup-node@v3 + with: + node-version: 18 + cache: 'npm' + + - name: Manage Version + run: | + git fetch --prune --unshallow --tags + GIT_SHA="$(git rev-parse --short HEAD)" + CUR_TAG="$(git tag -l | grep 'alpha\|beta' | tail -1)" + VER="$(yarn --silent app:version)" + echo "SHORT_SHA=$GIT_SHA" >> $GITHUB_ENV + echo "VER=$VER" >> $GITHUB_ENV + if [[ -z $CUR_TAG ]]; then + echo "OLD_PRE_TAG=NULL" >> $GITHUB_ENV + else + echo "OLD_PRE_TAG=$CUR_TAG" >> $GITHUB_ENV + fi + + - name: Build Artifact + run: | + yarn install + yarn build + tar -I zstd -cf ../MeowIndex-${VER}-nightly.tar.zst ./* + + - name: Generate Prerelease Release Notes + run: | + echo '### Nightly Release' >> ReleaseNotes.md + echo 'This nightly release is automatically built by github actions.' >> ReleaseNotes.md + echo '### The latest five updates are:' >> ReleaseNotes.md + git log -"5" --format="- %H %s" | sed '/^$/d' >> ReleaseNotes.md + + - name: Delete Old Prerelease + uses: dev-drprasad/delete-tag-and-release@v0.2.0 + with: + tag_name: ${{ env.OLD_PRE_TAG }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Publish GitHub Release + if: contains(github.event.head_commit.message, 'Release') == false + uses: ncipollo/release-action@v1.8.6 + with: + prerelease: true + bodyFile: ReleaseNotes.md + artifacts: "${{ env.BUILD_OUTPUT }}/*.zip" + tag: "v${{ env.VER }}-alpha" + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..4ee95e3 --- /dev/null +++ b/.npmignore @@ -0,0 +1 @@ +/public/mime/ diff --git a/package.json b/package.json index 07f0c22..f4a3de6 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "scripts": { "dev": "vite", "build": "vite build", - "serve": "vite preview" + "serve": "vite preview", + "app:version": "echo $npm_package_version" }, "license": "MIT", "devDependencies": {