mirror of
https://github.com/shanmiteko/LotteryAutoScript.git
synced 2026-06-04 21:01:17 +08:00
ci: pkg arm64 use podman
This commit is contained in:
parent
886ccff341
commit
82efbb4219
@ -1,4 +1,9 @@
|
|||||||
**/**
|
**/**
|
||||||
!lib/
|
!lib/
|
||||||
|
!script/
|
||||||
|
!test/
|
||||||
|
!main.js
|
||||||
!package.json
|
!package.json
|
||||||
!main.js
|
!env.example.js
|
||||||
|
!my_config.example.js
|
||||||
|
!README.md
|
||||||
|
|||||||
1
.github/workflows/mirror.yml
vendored
1
.github/workflows/mirror.yml
vendored
@ -12,6 +12,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
args: "https://gitlab.com/shanmiteko/LotteryAutoScript"
|
args: "https://gitlab.com/shanmiteko/LotteryAutoScript"
|
||||||
env:
|
env:
|
||||||
|
FORCE_PUSH: "true"
|
||||||
GITLAB_HOSTNAME: "gitlab.com"
|
GITLAB_HOSTNAME: "gitlab.com"
|
||||||
GITLAB_USERNAME: "shanmiteko"
|
GITLAB_USERNAME: "shanmiteko"
|
||||||
GITLAB_PASSWORD: ${{ secrets.GITLAB_PASSWORD }}
|
GITLAB_PASSWORD: ${{ secrets.GITLAB_PASSWORD }}
|
||||||
|
|||||||
49
.github/workflows/pkg.yml
vendored
49
.github/workflows/pkg.yml
vendored
@ -6,28 +6,65 @@ on:
|
|||||||
- "lib/**"
|
- "lib/**"
|
||||||
- "*.js"
|
- "*.js"
|
||||||
- "*.json"
|
- "*.json"
|
||||||
|
- ".github/workflows/pkg.yml"
|
||||||
|
- "script/build/pkg.sh"
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build_all:
|
x64:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
name: node${{ matrix.nodev }}-${{ matrix.platform }}-x64
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- platform: linux
|
||||||
|
nodev: 18
|
||||||
|
- platform: macos
|
||||||
|
nodev: 18
|
||||||
|
- platform: win
|
||||||
|
nodev: 18
|
||||||
|
- platform: win
|
||||||
|
nodev: 12
|
||||||
steps:
|
steps:
|
||||||
- name: "Checkout codes"
|
- name: "Checkout codes"
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- name: "Use Node.js"
|
- name: "Use Node.js"
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v1
|
||||||
with:
|
with:
|
||||||
node-version: "16"
|
node-version: "*"
|
||||||
- name: "Pkg this"
|
- name: "Pkg this"
|
||||||
run: |
|
run: |
|
||||||
sudo apt install zip unzip
|
|
||||||
npm install
|
npm install
|
||||||
npm run build_all
|
npm run pkg "node${{ matrix.nodev }}-${{ matrix.platform }}-x64"
|
||||||
- name: "Upload to artifact"
|
- name: "Upload to artifact"
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: all_platform
|
name: node${{ matrix.nodev }}-${{ matrix.platform }}-x64
|
||||||
path: dist/
|
path: "dist/*.zip"
|
||||||
|
- name: "Upload to release draft"
|
||||||
|
uses: xresloader/upload-to-github-release@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||||
|
with:
|
||||||
|
file: "dist/*.zip"
|
||||||
|
delete_file: "dist/*.zip"
|
||||||
|
tag_name: "v2"
|
||||||
|
overwrite: true
|
||||||
|
arm64:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: arm64
|
||||||
|
steps:
|
||||||
|
- name: "Checkout codes"
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: "Pkg this"
|
||||||
|
run: |
|
||||||
|
sudo podman run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
||||||
|
npm run pkg arm
|
||||||
|
- name: "Upload to artifact"
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: arm64
|
||||||
|
path: "dist/*.zip"
|
||||||
- name: "Upload to release draft"
|
- name: "Upload to release draft"
|
||||||
uses: xresloader/upload-to-github-release@v1
|
uses: xresloader/upload-to-github-release@v1
|
||||||
env:
|
env:
|
||||||
|
|||||||
22
Dockerfile.pkg-arm64
Normal file
22
Dockerfile.pkg-arm64
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
FROM arm64v8/node
|
||||||
|
|
||||||
|
WORKDIR /root/lottery
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN npm config set registry https://registry.npm.taobao.org && npm i
|
||||||
|
|
||||||
|
ENV DOWNLOAD_HOST=https://download.fastgit.org \
|
||||||
|
RELEASE_TAG=v3.4 \
|
||||||
|
NODEV=18.5.0 \
|
||||||
|
PKG_CACHE_PATH=/root/.pkg-cache \
|
||||||
|
PKG_IGNORE_TAG=true
|
||||||
|
|
||||||
|
RUN mkdir -p "${PKG_CACHE_PATH}" && \
|
||||||
|
curl -L "$DOWNLOAD_HOST/vercel/pkg-fetch/releases/download/$RELEASE_TAG/node-v$NODEV-linux-arm64" -o \
|
||||||
|
"${PKG_CACHE_PATH}/fetched-v$NODEV-linux-arm64" && \
|
||||||
|
curl -L "$DOWNLOAD_HOST/vercel/pkg-fetch/releases/download/$RELEASE_TAG/node-v$NODEV-linuxstatic-arm64" -o \
|
||||||
|
"${PKG_CACHE_PATH}/fetched-v$NODEV-linuxstatic-arm64"
|
||||||
|
|
||||||
|
CMD ["bash", "-c", "npx pkg -t node$NODEV-linuxstatic-arm64 -o dist/lottery-auto-script-node$NODEV-linuxstatic-arm64 . && \
|
||||||
|
npx pkg -t node$NODEV-linux-arm64 -o dist/lottery-auto-script-node$NODEV-linux-arm64 ."]
|
||||||
15
package.json
15
package.json
@ -9,7 +9,7 @@
|
|||||||
"clear": "node main.js clear",
|
"clear": "node main.js clear",
|
||||||
"check": "node main.js check",
|
"check": "node main.js check",
|
||||||
"update": "node main.js update",
|
"update": "node main.js update",
|
||||||
"build_all": "bash script/build/pkg.sh",
|
"pkg": "bash script/build/pkg.sh",
|
||||||
"changelog": "bash script/build/changelog.sh"
|
"changelog": "bash script/build/changelog.sh"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
@ -22,17 +22,6 @@
|
|||||||
"README.md"
|
"README.md"
|
||||||
],
|
],
|
||||||
"bin": "main.js",
|
"bin": "main.js",
|
||||||
"pkg": {
|
|
||||||
"targets": [
|
|
||||||
"node12-win-x64",
|
|
||||||
"node16-win-x64",
|
|
||||||
"node16-linux-x64",
|
|
||||||
"node16-macos-x64",
|
|
||||||
"node16-linuxstatic-arm64",
|
|
||||||
"node16-linuxstatic-armv7"
|
|
||||||
],
|
|
||||||
"outputPath": "dist"
|
|
||||||
},
|
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/shanmiteko/AutoScript.git"
|
"url": "https://github.com/shanmiteko/AutoScript.git"
|
||||||
@ -55,4 +44,4 @@
|
|||||||
"chalk": "^4.1.2",
|
"chalk": "^4.1.2",
|
||||||
"nodemailer": "^6.7.0"
|
"nodemailer": "^6.7.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,12 +1,14 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
ROOT=$PWD
|
ROOT=$PWD
|
||||||
README="README.md"
|
README="README.md"
|
||||||
TEMPLATE_CONFIG_FILE="my_config.example.js"
|
TEMPLATE_CONFIG_FILE="my_config.example.js"
|
||||||
TEMPLATE_ENV_FILE="env.example.js"
|
TEMPLATE_ENV_FILE="env.example.js"
|
||||||
CONFIG_FILE="my_config.js"
|
CONFIG_FILE="my_config.js"
|
||||||
ENV_FILE="env.js"
|
ENV_FILE="env.js"
|
||||||
TARGET_DIR="./dist"
|
TARGET_DIR="dist"
|
||||||
BIN_NAME="lottery"
|
BIN_NAME="lottery"
|
||||||
|
|
||||||
create_win_bat() {
|
create_win_bat() {
|
||||||
@ -17,28 +19,39 @@ if [ -d "$TARGET_DIR" ]; then
|
|||||||
rm -rf "$TARGET_DIR"
|
rm -rf "$TARGET_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
npx pkg .
|
if [[ -z "$1" ]]; then
|
||||||
|
$1=node18-linux-x64
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p $TARGET_DIR
|
||||||
|
|
||||||
|
if [[ "$1" == *"arm"* ]]; then
|
||||||
|
podman build -f Dockerfile.pkg-arm64 -t pkg-arm64
|
||||||
|
podman run -it --rm -v ${PWD}/dist:/root/lottery/dist pkg-arm64
|
||||||
|
elif [[ "$1" == *"x64"* ]]; then
|
||||||
|
OUTFILE="$TARGET_DIR/lottery-auto-script-$1"
|
||||||
|
npx pkg -t "$1" -o $OUTFILE .
|
||||||
|
fi
|
||||||
|
|
||||||
# Searching in the current directory
|
|
||||||
for file in "$TARGET_DIR/"*; do
|
for file in "$TARGET_DIR/"*; do
|
||||||
TMPDIR="${file%.exe}"
|
TMPDIR="${file%.exe}"
|
||||||
TMPDIR_NAME="${TMPDIR##*/}"
|
TMPDIR_NAME="${TMPDIR##*/}"
|
||||||
REMANE_FILE="$TARGET_DIR/$BIN_NAME"
|
REMANE_FILE="$TARGET_DIR/$BIN_NAME"
|
||||||
mv $file $REMANE_FILE
|
mv $file $REMANE_FILE
|
||||||
mkdir -p "$TMPDIR/"
|
mkdir -p "$TMPDIR.d/"
|
||||||
mv $REMANE_FILE "$TMPDIR/"
|
mv $REMANE_FILE "$TMPDIR.d/"
|
||||||
cp $README "$TMPDIR/"
|
cp $README "$TMPDIR.d/"
|
||||||
cp $TEMPLATE_CONFIG_FILE "$TMPDIR/$CONFIG_FILE"
|
cp $TEMPLATE_CONFIG_FILE "$TMPDIR.d/$CONFIG_FILE"
|
||||||
cp $TEMPLATE_ENV_FILE "$TMPDIR/$ENV_FILE"
|
cp $TEMPLATE_ENV_FILE "$TMPDIR.d/$ENV_FILE"
|
||||||
if [ "$(echo $file | grep '.exe')" ]; then
|
if [ "$(echo $file | grep '.exe')" ]; then
|
||||||
BATS=("start" "check" "clear" "update")
|
BATS=("start" "check" "clear" "update")
|
||||||
for item in "${BATS[@]}"; do
|
for item in "${BATS[@]}"; do
|
||||||
create_win_bat "${item}" >"$TMPDIR/$item.bat"
|
create_win_bat "${item}" >"$TMPDIR.d/$item.bat"
|
||||||
done
|
done
|
||||||
mv "$TMPDIR/$BIN_NAME" "$TMPDIR/$BIN_NAME.exe"
|
mv "$TMPDIR.d/$BIN_NAME" "$TMPDIR.d/$BIN_NAME.exe"
|
||||||
else
|
else
|
||||||
ZIP_NAME=latest_version0
|
ZIP_NAME=latest_version0
|
||||||
cat >"$TMPDIR/update.sh" <<-EOF
|
cat >"$TMPDIR.d/update.sh" <<-EOF
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
./lottery update
|
./lottery update
|
||||||
ZIP_NAME=$ZIP_NAME
|
ZIP_NAME=$ZIP_NAME
|
||||||
@ -49,7 +62,7 @@ for file in "$TARGET_DIR/"*; do
|
|||||||
fi
|
fi
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
cd $TMPDIR
|
cd $TMPDIR.d
|
||||||
zip -r "$TMPDIR_NAME.zip" .
|
zip -r "$TMPDIR_NAME.zip" .
|
||||||
mv "$TMPDIR_NAME.zip" ../
|
mv "$TMPDIR_NAME.zip" ../
|
||||||
cd $ROOT
|
cd $ROOT
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user