├── .github └── workflows │ ├── docker-hub.yml │ ├── file-customize.yml │ ├── file-dotnet.yml │ └── file-go.yml ├── LICENSE └── README.md /.github/workflows/docker-hub.yml: -------------------------------------------------------------------------------- 1 | name: '*构建镜像并推送至docker hub' 2 | 3 | on: 4 | repository_dispatch: 5 | workflow_dispatch: 6 | inputs: 7 | repoUrl: 8 | description: 'git仓库克隆url地址' 9 | required: true 10 | imageName: 11 | description: '构建镜像的名称,不填写根据git地址自动生成' 12 | required: false 13 | repoBranch : 14 | description: '指定git分支' 15 | required: false 16 | dockerFileUrl: 17 | description: '自定义DockerFile下载路径,可空' 18 | required: false 19 | shellUrl: 20 | description: '自定义构建前脚本下载路径,可空' 21 | required: false 22 | shell: 23 | description: '构建前运行shell命令,执行mv Dockerfile等操作' 24 | required: false 25 | platforms: 26 | description: '需要构建的平台' 27 | required: false 28 | default: linux/amd64,linux/arm64/v8 29 | tags: 30 | description: '自定义dockerTags,多个使用逗号分隔,非dockerhub使用完整tag(例ghcr.io/xxx/xxx)' 31 | required: false 32 | default: latest 33 | timeTagsFormat: 34 | description: '根据时间自动生成的dockerTag' 35 | type: choice 36 | default: 月-日_时-分-秒 37 | options: 38 | - 不生成时间tag 39 | - 年-月-日_时-分-秒 40 | - 年-月-日_时-分 41 | - 月-日_时-分-秒 42 | - 月-日_时-分 43 | timeTagsPrefix: 44 | description: '根据时间生成Tag的前缀' 45 | required: false 46 | 47 | jobs: 48 | build: 49 | runs-on: ubuntu-latest 50 | steps: 51 | - name: Check Out 52 | uses: actions/checkout@main 53 | 54 | - name: Setup timezone 55 | uses: zcong1993/setup-timezone@master 56 | with: 57 | timezone: Asia/Shanghai 58 | 59 | # 克隆目标,并且准备上下文 60 | - name: Git clone 61 | id: redy 62 | run: | 63 | rm -rf {*,.[^.]*,..?*} 64 | if [[ "${{ github.event.inputs.repoBranch }}" ]] ;then git clone --depth 1 -b "${{ github.event.inputs.repoBranch }}" "${{github.event.inputs.repoUrl}}" . ; else git clone --depth 1 "${{github.event.inputs.repoUrl}}" . ; fi 65 | if [[ "${{ github.event.inputs.dockerFileUrl }}" ]] ;then wget "${{github.event.inputs.dockerFileUrl}}" -O ./Dockerfile ; fi 66 | if [[ "${{ github.event.inputs.shellUrl }}" ]] ;then wget "${{github.event.inputs.shellUrl}}" -O /tmp/.customize_shell.sh ; chmod +x /tmp/.customize_shell.sh && /tmp/.customize_shell.sh; fi 67 | if [[ "${{ github.event.inputs.shell }}" ]] ;then ""${{github.event.inputs.shell}} ; fi 68 | dockerHubUsername=${{ secrets.DOCKER_HUB_USERNAME }} 69 | dockerHubPassword=${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} 70 | if [[ "${{ env.DOCKER_HUB_USERNAME }}" ]] ;then dockerHubUsername="${{env.DOCKER_HUB_USERNAME}}" ; fi 71 | if [[ "${{ env.DOCKER_HUB_ACCESS_TOKEN }}" ]] ;then githubPassword="${{env.DOCKER_HUB_ACCESS_TOKEN}}" ; fi 72 | if [[ "${{ env.tmpUsername }}" ]] ;then dockerHubUsername="${{env.tmpUsername}}" ; fi 73 | if [[ "${{ env.tmpToken }}" ]] ;then githubPassword="${{env.tmpToken}}" ; fi 74 | imageName=${{github.event.inputs.imageName}} 75 | if [[ ! "$imageName" ]] ; then 76 | imageName=$(basename "${{github.event.inputs.repoUrl}}" | awk -F '?' '{print $1}') 77 | imageName=$(echo "$imageName" | tr '[:upper:]' '[:lower:]') 78 | echo "auto docker image name ${{github.event.inputs.repoUrl}} => $imageName" 79 | fi 80 | echo "dockerHubUsername=$dockerHubUsername" >> $GITHUB_OUTPUT 81 | echo "dockerHubPassword=$dockerHubPassword" >> $GITHUB_OUTPUT 82 | echo "imageName=$imageName" >> $GITHUB_OUTPUT 83 | 84 | # docker login 85 | - name: Login to Docker Hub 86 | uses: docker/login-action@master 87 | with: 88 | username: ${{ steps.redy.outputs.dockerHubUsername }} 89 | password: ${{ steps.redy.outputs.dockerHubPassword }} 90 | 91 | # 设置 docker buildx 环境 92 | - name: Set up Docker Buildx 93 | id: buildx 94 | uses: docker/setup-buildx-action@master 95 | - name: Set up QEMU 96 | uses: docker/setup-qemu-action@master 97 | # build 前置操作 98 | - name: Docker before 99 | id: docker_before 100 | run: | 101 | image="${{ steps.redy.outputs.dockerHubUsername }}/${{ steps.redy.outputs.imageName }}" 102 | echo "original image $image" 103 | arr=(${image//\// }) 104 | image="" 105 | var_len=${#arr[*]} 106 | var_start=$(($var_len - 2)) 107 | var_end=$(($var_len - 1)) 108 | for ((i=$var_start; i<=$var_end ; i ++)); do image="${image}/${arr[$i]}"; done 109 | image=${image:1} 110 | tags="$image:latest" 111 | t="${{github.event.inputs.tags}}" 112 | if [[ "$t" ]] ; then 113 | tags="" 114 | echo "customize tags $t" 115 | arr=(${t//,/ }) 116 | for i in ${arr[*]}; do tags="$tags,${image}:$i"; done 117 | tags=${tags:1} 118 | fi 119 | if [[ "${{github.event.inputs.timeTagsFormat}}" != "不生成时间tag" ]] ; then 120 | timeFormat="+%m-%d_%H-%M-%S" 121 | if [[ "${{github.event.inputs.timeTagsFormat}}" == "年-月-日_时-分-秒" ]] ; then 122 | timeFormat="+%y-%m-%d_%H-%M-%S" 123 | elif [[ "${{github.event.inputs.timeTagsFormat}}" == "年-月-日_时-分" ]] ; then 124 | timeFormat="+%y-%m-%d_%H-%M" 125 | elif [[ "${{github.event.inputs.timeTagsFormat}}" == "月-日_时-分" ]] ; then 126 | timeFormat="+%m-%d_%H-%M" 127 | fi 128 | tags="$tags,$image:${{github.event.inputs.timeTagsPrefix}}$(date $timeFormat)" 129 | fi 130 | echo "target images $tags" 131 | echo "tags=$tags" >> $GITHUB_OUTPUT 132 | 133 | # build 并且 push docker 镜像 134 | - name: Build and push 135 | id: docker_build 136 | uses: docker/build-push-action@master 137 | with: 138 | context: . 139 | file: ./Dockerfile 140 | push: true 141 | tags: ${{steps.docker_before.outputs.tags}} 142 | platforms: ${{github.event.inputs.platforms}} 143 | 144 | # 打印 docker 镜像 SHA256 Hash 值 145 | - name: Image digest 146 | run: echo ${{ steps.docker_build.outputs.digest }} 147 | -------------------------------------------------------------------------------- /.github/workflows/file-customize.yml: -------------------------------------------------------------------------------- 1 | name: '自定义shell构建并下载' 2 | 3 | on: 4 | repository_dispatch: 5 | workflow_dispatch: 6 | inputs: 7 | SETTING_SHELL_URL: 8 | description: '设置构建环境的shell地址' 9 | required: false 10 | GIT_REPO_URL: 11 | description: 'git仓库地址' 12 | required: false 13 | GIT_REPO_BRANCH: 14 | description: 'git仓库分支' 15 | required: false 16 | BUILD_BEFORE_SHELL_URL: 17 | description: '构建前shell地址' 18 | required: false 19 | BUILD_SHELL_URL: 20 | description: '构建shell命令地址' 21 | required: true 22 | BUILD_AFTER_SHELL_URL: 23 | description: '构建后shell命令地址' 24 | required: false 25 | BUILD_TARGET_PATH: 26 | description: '构建产物路径' 27 | required: true 28 | default: './dist/*' 29 | UPLOAD_RELEASE: 30 | description: '是否上传到RELEASE页面' 31 | required: false 32 | default: false 33 | type: boolean 34 | UPLOAD_TRANSFER: 35 | description: '上传服务,如wet,见github.com/Mikubill/transfer#support' 36 | required: false 37 | UPLOAD_TAG: 38 | description: '上传文件用的TAG,默认使用构建时间' 39 | required: false 40 | 41 | jobs: 42 | build: 43 | runs-on: ubuntu-latest 44 | steps: 45 | - name: Check Out 46 | uses: actions/checkout@main 47 | # 产生tag 48 | - name: Generate tag 49 | id: tag 50 | run: | 51 | tag=build-customize_$(date +'%m-%d_%H-%M-%S') 52 | [ ! "${{github.event.inputs.UPLOAD_TAG}}" = "" ] && tag=${{github.event.inputs.UPLOAD_TAG}} 53 | echo "tag=$tag" >> $GITHUB_OUTPUT 54 | 55 | # 开始构建 56 | - name: Build 57 | id: build 58 | run: | 59 | rm -rf /tmp/dist 60 | mkdir -p /tmp/dist 61 | echo -e "github actions build\nstart time: $(date +'%Y-%m-%d %H:%M:%S')\n" > release.txt 62 | start=$(date +%s) 63 | if [[ "${{ github.event.inputs.SETTING_SHELL_URL }}" ]] ;then wget "${{github.event.inputs.SETTING_SHELL_URL}}" -O /tmp/.customize_shell.sh ; chmod +x /tmp/.customize_shell.sh && /tmp/.customize_shell.sh | tee /tmp/build_log/setting.log; fi 64 | if [[ "${{ github.event.inputs.GIT_REPO_URL }}" ]] && if [[ "${{ github.event.inputs.GIT_REPO_BRANCH }}" ]] ;then git clone --depth 1 -b "${{ github.event.inputs.GIT_REPO_BRANCH }}" "${{github.event.inputs.GIT_REPO_URL}}" . ; else git clone --depth 1 "${{github.event.inputs.GIT_REPO_URL}}" . ; fi 65 | if [[ "${{ github.event.inputs.BUILD_BEFORE_SHELL_URL }}" ]] ;then wget "${{github.event.inputs.SETTING_SHELL_URL}}" -O /tmp/.customize_shell.sh ; chmod +x /tmp/.customize_shell.sh && /tmp/.customize_shell.sh | tee /tmp/build_log/before.log; fi 66 | wget "${{github.event.inputs.SETTING_SHELL_URL}}" -O /tmp/.customize_shell.sh ; chmod +x /tmp/.customize_shell.sh && /tmp/.customize_shell.sh | tee /tmp/build_log/build.log 67 | if [[ "${{ github.event.inputs.BUILD_AFTER_SHELL_URL }}" ]] ;then wget "${{github.event.inputs.SETTING_SHELL_URL}}" -O /tmp/.customize_shell.sh ; chmod +x /tmp/.customize_shell.sh && /tmp/.customize_shell.sh | tee /tmp/build_log/after.log; fi 68 | end=$(date +%s) 69 | take=$(( end - start )) 70 | echo "end time: $(date +'%Y-%m-%d %H:%M:%S')" >> release.txt 71 | echo "build use ${take}s" >> release.txt 72 | cp -r ${{ github.event.inputs.BUILD_TARGET_PATH }} /tmp/dist 73 | tar -zcvf /tmp/dist.tar.gz -C /tmp/dist $(ls /tmp/dist) > /dev/null 74 | 75 | # 上传构建日志 76 | - name: Upload build logs 77 | uses: actions/upload-artifact@main 78 | with: 79 | name: log_${{ steps.tag.outputs.tag }} 80 | path: /tmp/build_log 81 | retention-days: 1 82 | 83 | # 上传构建产物 84 | - name: Upload firmware directory 85 | uses: actions/upload-artifact@main 86 | with: 87 | name: ${{ steps.tag.outputs.tag }} 88 | path: /tmp/dist.tar.gz 89 | retention-days: 1 90 | 91 | # 上传到中转服务 92 | - name: Upload firmware to transfer 93 | if: github.event.inputs.UPLOAD_TRANSFER && !failure() && !cancelled() 94 | run: | 95 | curl -fsSL git.io/file-transfer | sh 96 | ./transfer ${{ github.event.inputs.UPLOAD_TRANSFER }} --no-progress /tmp/dist.tar.gz 2>&1 | tee transfer.log 97 | url=$(cat transfer.log | grep https | cut -f3 -d" ") 98 | echo "🔗 External Download Link: $url" >> release.txt 99 | echo "::warning ::External Download Link: $url" 100 | 101 | # 生成release 102 | - name: Upload firmware to release 103 | uses: softprops/action-gh-release@master 104 | if: github.event.inputs.UPLOAD_RELEASE == 'true' && !failure() && !cancelled() 105 | env: 106 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 107 | with: 108 | tag_name: ${{ steps.tag.outputs.tag }} 109 | body_path: release.txt 110 | files: /tmp/dist.tar.gz 111 | -------------------------------------------------------------------------------- /.github/workflows/file-dotnet.yml: -------------------------------------------------------------------------------- 1 | name: 'c#构建并下载' 2 | 3 | on: 4 | repository_dispatch: 5 | workflow_dispatch: 6 | inputs: 7 | repoPath: 8 | description: 'git仓库路径' 9 | required: true 10 | repoBranch: 11 | description: '指定分支' 12 | required: false 13 | shellUrl: 14 | description: '构建前运行脚本url' 15 | required: false 16 | shell: 17 | description: '构建前运行shell命令,cd或者restore等' 18 | required: false 19 | DOTNET_VERSION: 20 | description: '.net版本' 21 | required: false 22 | default: '6.x' 23 | UPLOAD_RELEASE: 24 | description: '是否上传到RELEASE页面' 25 | required: false 26 | default: false 27 | type: boolean 28 | UPLOAD_TRANSFER: 29 | description: '上传服务,如wet,见github.com/Mikubill/transfer#support' 30 | required: false 31 | UPLOAD_TAG: 32 | description: '上传文件用的TAG,默认使用构建时间' 33 | required: false 34 | platforms: 35 | description: '需要构建的架构' 36 | required: true 37 | default: win-x64,linux-x64,linux-arm64 38 | 39 | jobs: 40 | build: 41 | runs-on: ubuntu-latest 42 | steps: 43 | - name: Check Out 44 | uses: actions/checkout@main 45 | # 产生tag 46 | - name: Generate tag 47 | id: tag 48 | run: | 49 | tag=build-dotnet_$(date +'%m-%d_%H-%M-%S') 50 | [ ! "${{github.event.inputs.UPLOAD_TAG}}" = "" ] && tag=${{github.event.inputs.UPLOAD_TAG}} 51 | echo "tag=$tag" >> $GITHUB_OUTPUT 52 | 53 | # 设置构建环境依赖 54 | - name: Set up .NET Core 55 | uses: actions/setup-dotnet@main 56 | with: 57 | dotnet-version: ${{ github.event.inputs.DOTNET_VERSION }} 58 | 59 | # 克隆目标,并且准备上下文 60 | - name: Git clone 61 | run: | 62 | rm -rf {*,.[^.]*,..?*} 63 | if [[ "${{ github.event.inputs.repoBranch }}" ]] ;then git clone --depth 1 -b "${{ github.event.inputs.repoBranch }}" "${{github.event.inputs.repoPath}}" . ; else git clone --depth 1 "${{github.event.inputs.repoPath}}" . ; fi 64 | if [[ "${{ github.event.inputs.shellUrl }}" ]] ;then wget "${{github.event.inputs.shellUrl}}" -O /tmp/.customize_shell.sh ; chmod +x /tmp/.customize_shell.sh && /tmp/.customize_shell.sh; fi 65 | 66 | # 开始构建 67 | - name: Build 68 | id: build 69 | run: | 70 | rm -rf /tmp/dist 71 | mkdir -p /tmp/dist 72 | mkdir -p /tmp/dist_tmp 73 | mkdir -p /tmp/build_log 74 | dotnet restore 75 | echo -e "github actions build\nstart time: $(date +'%Y-%m-%d %H:%M:%S')\n" > release.txt 76 | start=$(date +%s) 77 | platforms=${{ github.event.inputs.platforms }} 78 | echo "start build at $start, all platforms: $platforms" 79 | platforms1=(${platforms//,/ }) 80 | if [[ "${{ github.event.inputs.shell }}" ]] ;then ""${{github.event.inputs.shell}} ; fi 81 | for platforms2 in ${platforms1[*]}; do 82 | start1=$(date +%s) 83 | echo "strart build $platforms2" 84 | echo "/tmp/dist/${platforms2}" >> /tmp/files 85 | # mkdir -p /tmp/src/${platforms2} &&cp -r ./* /tmp/src/${platforms2}/&& cd /tmp/src/${platforms2} &&\ 86 | dotnet publish -c Release -p:PublishSingleFile=true -p:PublishTrimmed=true -o "/tmp/dist_tmp/${platforms2}" > "/tmp/build_log/${platforms2}.log" 2>&1 \ 87 | && echo "build over $platforms2 use $(( $(date +%s) - start ))s" \ 88 | && echo "${platforms2} build use $(( $(date +%s) - start ))s" >> release.txt \ 89 | && echo "::notice ::$platforms2 build use $(( $(date +%s) - start1 ))s" \ 90 | && tar -zcvf /tmp/dist/${platforms2}.tar.gz -C /tmp/dist_tmp/${platforms2}/ $(ls /tmp/dist_tmp/${platforms2}) > /dev/null \ 91 | || (echo "::error ::build fail $platforms2 use $(( $(date +%s) - start ))s" && cat /tmp/build_log/${platforms2}.log) 92 | done 93 | wait 94 | end=$(date +%s) 95 | take=$(( end - start )) 96 | echo "end time: $(date +'%Y-%m-%d %H:%M:%S')" >> release.txt 97 | echo -e "all build use ${take}s\n" >> release.txt 98 | echo "::notice ::all build use $(( $(date +%s) - start ))s" 99 | tar -zcvf dist.tar.gz -C /tmp/dist/ $(ls /tmp/dist) > /dev/null 100 | 101 | # 上传构建日志 102 | - name: Upload build logs 103 | uses: actions/upload-artifact@main 104 | with: 105 | name: log_${{ steps.tag.outputs.tag }} 106 | path: /tmp/build_log 107 | retention-days: 1 108 | 109 | # 上传构建产物 110 | - name: Upload firmware directory 111 | uses: actions/upload-artifact@main 112 | with: 113 | name: ${{ steps.tag.outputs.tag }} 114 | path: dist.tar.gz 115 | retention-days: 1 116 | 117 | # 上传到中转服务 118 | - name: Upload firmware to transfer 119 | if: github.event.inputs.UPLOAD_TRANSFER && !failure() && !cancelled() 120 | run: | 121 | curl -fsSL git.io/file-transfer | sh 122 | ./transfer ${{ github.event.inputs.UPLOAD_TRANSFER }} --no-progress dist.tar.gz 2>&1 | tee transfer.log 123 | url=$(cat transfer.log | grep https | cut -f3 -d" ") 124 | echo "🔗 External Download Link: $url" >> release.txt 125 | echo "::warning ::External Download Link: $url" 126 | 127 | # 生成release 128 | - name: Upload firmware to release 129 | uses: softprops/action-gh-release@master 130 | if: github.event.inputs.UPLOAD_RELEASE == 'true' && !failure() && !cancelled() 131 | env: 132 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 133 | with: 134 | tag_name: ${{ steps.tag.outputs.tag }} 135 | body_path: release.txt 136 | files: /tmp/dist/* 137 | -------------------------------------------------------------------------------- /.github/workflows/file-go.yml: -------------------------------------------------------------------------------- 1 | name: 'go构建并下载' 2 | 3 | on: 4 | repository_dispatch: 5 | workflow_dispatch: 6 | inputs: 7 | repoPath: 8 | description: 'git仓库路径' 9 | required: true 10 | repoBranch: 11 | description: '指定分支' 12 | required: false 13 | shellUrl: 14 | description: '构建前运行脚本url' 15 | required: false 16 | shell: 17 | description: '构建前运行shell命令:cd,go mod等' 18 | required: false 19 | GO_VERSION: 20 | description: 'go版本,默认最新go稳定版' 21 | required: true 22 | default: 'stable' 23 | UPLOAD_RELEASE: 24 | description: '是否上传到RELEASE页面' 25 | required: false 26 | type: boolean 27 | default: false 28 | UPLOAD_TRANSFER: 29 | description: '上传服务,如wet,见github.com/Mikubill/transfer#support' 30 | required: false 31 | UPLOAD_TAG: 32 | description: '上传文件用的TAG,默认使用构建时间' 33 | required: false 34 | platforms: 35 | description: '需要构建的平台' 36 | required: true 37 | default: linux/amd64,linux/arm64 38 | 39 | jobs: 40 | build: 41 | runs-on: ubuntu-latest 42 | steps: 43 | - name: Check Out 44 | uses: actions/checkout@main 45 | # 产生tag 46 | - name: Generate tag 47 | id: tag 48 | run: | 49 | tag=build-go_$(date +'%m-%d_%H-%M-%S') 50 | [ ! "${{github.event.inputs.UPLOAD_TAG}}" = "" ] && tag=${{github.event.inputs.UPLOAD_TAG}} 51 | echo "tag=$tag" >> $GITHUB_OUTPUT 52 | 53 | # 设置go环境 54 | - name: Set up Go 55 | uses: actions/setup-go@main 56 | with: 57 | go-version: ${{ github.event.inputs.GO_VERSION }} 58 | 59 | # 克隆目标,并且准备上下文 60 | - name: Git clone 61 | run: | 62 | rm -rf {*,.[^.]*,..?*} 63 | if [[ "${{ github.event.inputs.repoBranch }}" ]] ;then git clone --depth 1 -b "${{ github.event.inputs.repoBranch }}" "${{github.event.inputs.repoPath}}" . ; else git clone --depth 1 "${{github.event.inputs.repoPath}}" . ; fi 64 | if [[ "${{ github.event.inputs.shellUrl }}" ]] ;then wget "${{github.event.inputs.shellUrl}}" -O /tmp/.customize_shell.sh ; chmod +x /tmp/.customize_shell.sh && /tmp/.customize_shell.sh; fi 65 | 66 | # 开始构建 67 | - name: Build 68 | id: build 69 | run: | 70 | rm -rf /tmp/dist 71 | mkdir -p /tmp/dist 72 | mkdir -p /tmp/build_log 73 | echo -e "github actions build\nstart time: $(date +'%Y-%m-%d %H:%M:%S')\n" > release.txt 74 | start=$(date +%s) 75 | platforms=${{ github.event.inputs.platforms }} 76 | echo "start build at $start, all platforms: $platforms" 77 | platforms1=(${platforms//,/ }) 78 | if [[ "${{ github.event.inputs.shell }}" ]] ;then ""${{github.event.inputs.shell}} ; fi 79 | for platforms2 in ${platforms1[*]}; do 80 | p=(${platforms2//\// }) 81 | V_OS="${p[0]}" 82 | V_ARCH="${p[1]}" 83 | V_SUFFIX="" 84 | [ "${V_OS}" == 'windows' ] && V_SUFFIX='.exe' 85 | echo "strart build $platforms2 -> ${V_OS}_${V_ARCH}" 86 | echo "/tmp/dist/${V_OS}_${V_ARCH}" >> /tmp/files 87 | CGO_ENABLED=0 GOOS=${V_OS} GOARCH=${V_ARCH} go build -o "/tmp/dist/${V_OS}_${V_ARCH}${V_SUFFIX}" -ldflags="-w -s" -v 2>&1 | sed "s/^/[${V_OS}_${V_ARCH}]/" | tee "/tmp/build_log/${V_OS}_${V_ARCH}.log" \ 88 | && echo "build over $platforms2 -> ${V_OS}_${V_ARCH} use $(( $(date +%s) - start ))s" \ 89 | && echo "${V_OS}_${V_ARCH} build use $(( $(date +%s) - start ))s" >> release.txt \ 90 | && echo "::notice ::$platforms2 -> ${V_OS}_${V_ARCH} build use $(( $(date +%s) - start ))s" \ 91 | || (echo "::error ::build fail $platforms2 -> ${V_OS}_${V_ARCH} use $(( $(date +%s) - start ))s" && cat /tmp/build_log/${V_OS}_${V_ARCH}.log) & 92 | done 93 | wait 94 | end=$(date +%s) 95 | take=$(( end - start )) 96 | echo "end time: $(date +'%Y-%m-%d %H:%M:%S')" >> release.txt 97 | echo -e "all build use ${take}s\n" >> release.txt 98 | tar -zcvf dist.tar.gz -C /tmp/dist $(ls /tmp/dist) > /dev/null 99 | 100 | # 上传构建日志 101 | - name: Upload build logs 102 | uses: actions/upload-artifact@main 103 | with: 104 | name: log_${{ steps.tag.outputs.tag }} 105 | path: /tmp/build_log 106 | retention-days: 1 107 | 108 | # 上传构建产物 109 | - name: Upload firmware directory 110 | uses: actions/upload-artifact@main 111 | with: 112 | name: ${{ steps.tag.outputs.tag }} 113 | path: dist.tar.gz 114 | retention-days: 1 115 | 116 | # 上传到中转服务 117 | - name: Upload firmware to transfer 118 | if: github.event.inputs.UPLOAD_TRANSFER && !failure() && !cancelled() 119 | run: | 120 | curl -fsSL git.io/file-transfer | sh 121 | ./transfer ${{ github.event.inputs.UPLOAD_TRANSFER }} --no-progress dist.tar.gz 2>&1 | tee transfer.log 122 | url=$(cat transfer.log | grep https | cut -f3 -d" ") 123 | echo "🔗 External Download Link: $url" >> release.txt 124 | echo "::warning ::External Download Link: $url" 125 | 126 | # 生成release 127 | - name: Upload firmware to release 128 | uses: softprops/action-gh-release@master 129 | if: github.event.inputs.UPLOAD_RELEASE == 'true' && !failure() && !cancelled() 130 | env: 131 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 132 | with: 133 | tag_name: ${{ steps.tag.outputs.tag }} 134 | body_path: release.txt 135 | files: /tmp/dist/* 136 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Actions-buildUtils 2 | [![](https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Fmzzsfy%2FActions-buildUtils&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false)](https://github.com/mzzsfy) 3 | 4 | 一些通用的白嫖github Actions的构建工具,记得给我点个star❤️ https://github.com/mzzsfy/Actions-buildUtils 5 | 6 | ## 使用教程 7 | 8 | ### 填写参数 9 | 10 | fork本仓库 ( **⚠️ GitHub 会根据此上游存储库计算您的 fork GitHub Actions 使用情况,这可能会导致此上游存储库被 GitHub 员工(如 [MagiskOnWSA](https://github.com/LSPosed/MagiskOnWSA))禁用,所以如果你需要长期或者大量的使用Actions,请使用非fork方法,方法见后文,感谢** ) 11 | 12 | 按如下操作添加参数 13 | ![image](https://user-images.githubusercontent.com/43053461/204208295-4004ee4a-30dc-4e7f-9587-5c8f9edb52cd.png) 14 | 15 | 重要参数 16 | - `DOCKER_HUB_USERNAME` docker-hub 用户名 17 | - `DOCKER_HUB_ACCESS_TOKEN` docker-hub 读写权限token或者密码,建议使用token 18 | 19 | ### 构建 20 | 21 | 按如下步骤点击 22 | 23 | ![image](https://github.com/mzzsfy/Actions-buildUtils/assets/43053461/72f501a2-744d-4178-b864-8ca897594af7) 24 | 25 | ![image](https://github.com/mzzsfy/Actions-buildUtils/assets/43053461/4d38324c-5f28-4281-8fc0-875789ceabb3) 26 | 27 | 28 | 快乐白嫖,记得给我点个star https://github.com/mzzsfy/Actions-buildUtils 29 | 30 | ### 私有库用法 31 | 32 | github: 33 | 首先创建token 34 | https://github.com/settings/tokens/new 35 | 36 | git地址写法`https://oauth2:@github.com/name/repo` 37 | 38 | 其它git服务 39 | 40 | git地址写法`https://:@` 41 | 42 | ## 非fork同步本仓库 43 | 44 | 因为 GitHub 会根据此上游存储库计算您的 fork GitHub Actions 使用情况,这可能会导致此上游存储库被 GitHub 员工(如 [MagiskOnWSA](https://github.com/LSPosed/MagiskOnWSA))禁用 45 | 所以你如果你需要长期或者大量的使用Actions,请不要使用fork,以下提供几种参考方法 46 | 47 | ### 使用 git 命令 48 | 49 | 参考官方文档 大致逻辑是git clone 本仓库, 推送为新仓库,使用本地仓库做中转,实现文件的同步,后面面几种方法是不支持同步更改的 50 | https://docs.github.com/en/repositories/creating-and-managing-repositories/duplicating-a-repository 51 | 52 | ### 使用导入 53 | ![image](https://user-images.githubusercontent.com/43053461/233926542-62677cc0-036c-4c64-8f16-47c26db3ea9f.png) 54 | 填入本仓库地址 55 | ![image](https://user-images.githubusercontent.com/43053461/233927154-d7f7e941-a569-4836-8946-6f1c13cc0cc3.png) 56 | 开启Actions 57 | ![image](https://user-images.githubusercontent.com/43053461/233927826-aaa1ff17-df06-4989-bec9-f59df6b80dac.png) 58 | 59 | ### 使用模板生成 60 | 61 | ![image](https://user-images.githubusercontent.com/43053461/233928835-81551763-7137-4a86-9d06-262e664c936c.png) 62 | 63 | 模板生成不确定是否能规避该风险,建议优先使用前面的方法 64 | --------------------------------------------------------------------------------