-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
87 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
name: Release-Tag-Work | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*.*.*' | ||
|
||
jobs: | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Get version | ||
id: get_version | ||
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} | ||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.16 | ||
- name: Build | ||
run: | | ||
apt install gcc-aarch64-linux-gnu | ||
apt install gcc-mingw-w64-x86-64 | ||
make | ||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@master | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.TOKEN }} # 之前GitHub添加的Token | ||
with: | ||
tag_name: ${{ github.ref }} # (tag)标签名称 | ||
release_name: wechat-backup-${{ steps.get_version.outputs.VERSION }} | ||
draft: false # 是否是草稿 | ||
prerelease: false # 是否是预发布 | ||
# 上传构建结果到 Release(把打包的tgz上传到Release) | ||
- name: build TAR PACKAGE | ||
run: | | ||
tar -czvf wechat-backup-linux.tar.gz ./dist/linux | ||
tar -czvf wechat-backup-arm64.tar.gz ./dist/linux-arm64 | ||
tar -czvf wechat-backup-windows.tar.gz ./dist/windows | ||
- name: Upload Release Linux | ||
id: upload-release-linux | ||
uses: actions/upload-release-asset@master | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} # (tag)标签名称 | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} # 上传地址,通过创建Release获取到的 | ||
asset_path: ./wechat-backup-linux.tar.gz # 要上传文件 | ||
asset_name: wechat-backup_linux_${{ steps.get_version.outputs.VERSION }}.tar.gz # 上传后的文件名 | ||
asset_content_type: application/gzip | ||
|
||
- name: Upload Release Arm64 | ||
id: upload-release-arm64 | ||
uses: actions/upload-release-asset@master | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} # (tag)标签名称 | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} # 上传地址,通过创建Release获取到的 | ||
asset_path: ./wechat-backup-arm64.tar.gz # 要上传文件 | ||
asset_name: wechat-backup_arm64_${{ steps.get_version.outputs.VERSION }}.tar.gz # 上传后的文件名 | ||
asset_content_type: application/gzip | ||
- name: Upload Release windows | ||
id: upload-release-windows | ||
uses: actions/upload-release-asset@master | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} # (tag)标签名称 | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} # 上传地址,通过创建Release获取到的 | ||
asset_path: ./wechat-backup-windows.tar.gz # 要上传文件 | ||
asset_name: wechat-backup_windows_${{ steps.get_version.outputs.VERSION }}.tar.gz # 上传后的文件名 | ||
asset_content_type: application/gzip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,22 @@ | ||
export GO111MODULE=on | ||
binary_name=wechat-backup | ||
|
||
all: wechat-backup | ||
|
||
all: ${binary_name}.linux ${binary_name}.windows ${binary_name}.linux-arm64 | ||
LDFLAGS = -s -w | ||
ifdef STATIC | ||
LDFLAGS += -linkmode external -extldflags '-static' | ||
CC = /usr/bin/musl-gcc | ||
export CC | ||
endif | ||
|
||
wechat-backup: | ||
go build -ldflags="$(LDFLAGS)" -o wechat-backup . | ||
$(binary_name): | ||
go build -ldflags="$(LDFLAGS)" -o $(binary_name) . | ||
|
||
wechat-backup.linux: | ||
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 CC=x86_64-linux-musl-gcc CGO_LDFLAGS="-static" go build -ldflags="$(LDFLAGS)" -o wechat-backup . | ||
# Please execute the `apt install gcc-arm-linux-gnueabihf` command before using it. | ||
wechat-backup.linux-arm: | ||
CGO_ENABLED=1 GOOS=linux GOARCH=arm CC=arm-linux-gnueabihf-gcc CGO_LDFLAGS="-static" go build -ldflags="$(LDFLAGS)" -o wechat-backup . | ||
# Please execute the `apt install gcc-aarch64-linux-gnu` command before using it. | ||
wechat-backup.linux-arm64: | ||
CGO_ENABLED=1 GOOS=linux GOARCH=arm CC=arm-linux-gnueabihf-gcc CGO_LDFLAGS="-static" go build -ldflags="$(LDFLAGS)" -o wechat-backup . | ||
$(binary_name).linux: | ||
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 CGO_LDFLAGS="-static" go build -ldflags="$(LDFLAGS)" -o dist/linux/$(binary_name) . | ||
# Please execute the `apt install gcc-aarch64-linux-gnu` command before using it. | ||
$(binary_name).linux-arm64: | ||
CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc CGO_LDFLAGS="-static" go build -ldflags="$(LDFLAGS)" -o dist/linux-arm64/$(binary_name) . | ||
# Please execute the `apt install gcc-mingw-w64-x86-64` command before using it. | ||
wechat-backup.windows: | ||
CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc go build -ldflags="$(LDFLAGS)" -buildmode exe -o wechat-backup.exe . | ||
$(binary_name).windows: | ||
CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc go build -ldflags="$(LDFLAGS)" -buildmode exe -o dist/windows/$(binary_name).exe . |