chore: update release actions Close #58

pull/88/head
ᴍᴏᴏɴD4ʀᴋ 3 years ago committed by GitHub
parent 204e20aa18
commit 5500de2aaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 268
      .github/workflows/release.yml

@ -4,141 +4,135 @@ on:
types: [created] types: [created]
jobs: jobs:
build: build:
name: Build Binary runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, macos-latest, ubuntu-latest]
arch: [amd64, '386']
include:
- os: windows-latest
goos: windows
bin: 'hack-browser-data.exe'
args: -9
releaseos: windows
- os: macos-latest
goos: darwin
bin: 'hack-browser-data'
args: -9
releaseos: osx
- os: ubuntu-latest
goos: linux
bin: 'hack-browser-data'
args: -9
releaseos: linux
exclude:
- os: macos-latest
arch: '386'
- os: windows-latest
arch: '386'
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.15
- if: matrix.os == 'ubuntu-latest'
run: sudo apt-get update && sudo apt-get install -y gcc-multilib
- if: matrix.arch == '386'
run: echo "RELEASE=hack-browser-data-${{ github.event.release.tag_name}}-${{ matrix.releaseos}}-32bit" >> $GITHUB_ENV
- if: matrix.arch == 'amd64'
run: echo "RELEASE=hack-browser-data-${{ github.event.release.tag_name}}-${{ matrix.releaseos}}-64bit" >> $GITHUB_ENV
- if: matrix.os == 'windows-latest'
shell: powershell
run: echo "RELEASE=hack-browser-data-${{ github.event.release.tag_name}}-${{ matrix.releaseos}}-64bit" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
- uses: actions/checkout@v2
- name: Build ${{ matrix.goos }}/${{ matrix.arch }}
run: go build -ldflags '-w -s' -o ${{ matrix.bin }}
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.arch }}
CGO_ENABLED: 1
- uses: svenstaro/upx-action@v2
with:
args: ${{ matrix.args }}
file: ${{ matrix.bin }}
- name: Upload to artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ env.RELEASE }}
path: ${{ matrix.bin }}
package:
name: Package Assets
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
path: bin
- name: Package Releases
run: |
mkdir releases;
for RELEASE_DIR in bin/*
do
echo "Creating release $RELEASE_DIR"
for BINARY in $RELEASE_DIR/*
do
chmod 777 $BINARY;
cp $BINARY .;
zip -r releases/$(basename $RELEASE_DIR).zip \
$(basename ${BINARY}) \
README.md \
README_ZH.md;
rm $BINARY;
done
done
- name: Upload to artifacts
uses: actions/upload-artifact@v2
with:
name: releases
path: releases/*.zip
upload: steps:
name: Upload to the Release - name: Checkout source
runs-on: ubuntu-latest uses: actions/checkout@v1
needs: package
steps: - name: Use Golang
- uses: actions/download-artifact@v2 uses: actions/setup-go@v1
with: with:
name: releases go-version: "1.15"
path: releases/
- name: Upload Archives to Release -
env: name: Build with xgo
UPLOAD_URL: ${{ github.event.release.upload_url }} uses: crazy-max/ghaction-xgo@v1
API_HEADER: "Accept: application/vnd.github.v3+json" with:
AUTH_HEADER: "Authorization: token ${{ secrets.GITHUB_TOKEN }}" xgo_version: latest
run: | go_version: ${{ matrix.go_version }}
UPLOAD_URL=$(echo -n $UPLOAD_URL | sed s/\{.*//g) dest: build
for FILE in releases/* prefix: hack-browser-data
do targets: windows/amd64,windows/386,linux/386,linux/amd64,linux/arm,linux/arm64,darwin/amd64
echo "Uploading ${FILE}"; v: true
curl \ x: false
-H "${API_HEADER}" \ race: false
-H "${AUTH_HEADER}" \ ldflags: -s -w
-H "Content-Type: $(file -b --mime-type ${FILE})" \ buildmode: default
--data-binary "@${FILE}" \
"${UPLOAD_URL}?name=$(basename ${FILE})"; - name: Set Variable
done run: |
- name: Generate SHA256 Hashes echo "RELEASE_WIN32=hack-browser-data-${{ github.event.release.tag_name}}windows-32bit" >> $GITHUB_ENV
env: echo "RELEASE_WIN64=hack-browser-data-${{ github.event.release.tag_name}}windows-64bit" >> $GITHUB_ENV
API_HEADER: "Accept: application/vnd.github.v3+json" echo "RELEASE_OSX=hack-browser-data-${{ github.event.release.tag_name}}osx-64bit" >> $GITHUB_ENV
AUTH_HEADER: "Authorization: token ${{ secrets.GITHUB_TOKEN }}" echo "RELEASE_Linux386=hack-browser-data-${{ github.event.release.tag_name}}linux-386" >> $GITHUB_ENV
RELEASE_URL: ${{ github.event.release.url }} echo "RELEASE_LinuxARM64=hack-browser-data-${{ github.event.release.tag_name}}linux-arm64" >> $GITHUB_ENV
run: | echo "RELEASE_LinuxAMD64=hack-browser-data-${{ github.event.release.tag_name}}linux-amd64" >> $GITHUB_ENV
HASH_TABLE="| SHA256 Hash | Filename |" echo "RELEASE_LinuxARM=hack-browser-data-${{ github.event.release.tag_name}}linux-arm" >> $GITHUB_ENV
HASH_TABLE="${HASH_TABLE}\n|-----|-----|\n" - name: Build zip
for FILE in releases/* run: |
do mv build/hack-browser-data-windows*386.exe "$RELEASE_WIN32".exe
FILENAME=$(basename ${FILE}) mv build/hack-browser-data-windows*amd64.exe "$RELEASE_WIN64".exe
HASH=$(sha256sum ${FILE} | cut -d ' ' -f 1) mv build/hack-browser-data-linux-*386 "$RELEASE_Linux386"
HASH_TABLE="${HASH_TABLE}|${HASH}|${FILENAME}|\n" mv build/hack-browser-data-linux-*amd64 "$RELEASE_LinuxAMD64"
done mv build/hack-browser-data-linux-*arm64 "$RELEASE_LinuxARM64"
echo "${HASH_TABLE}" mv build/hack-browser-data-linux-*arm-* "$RELEASE_LinuxARM"
curl \ mv build/hack-browser-data-darwin-*amd64 "$RELEASE_OSX"
-XPATCH \ zip "$RELEASE_WIN32".zip "$RELEASE_WIN32".exe
-H "${API_HEADER}" \ zip "$RELEASE_WIN64".zip "$RELEASE_WIN64".exe
-H "${AUTH_HEADER}" \ zip "$RELEASE_Linux386".zip "$RELEASE_Linux386"
-H "Content-Type: application/json" \ zip "$RELEASE_LinuxAMD64".zip "$RELEASE_LinuxAMD64"
-d "{\"body\": \"${HASH_TABLE}\"}" \ zip "$RELEASE_LinuxARM64".zip "$RELEASE_Linux386"
"${RELEASE_URL}"; zip "$RELEASE_LinuxARM".zip "$RELEASE_LinuxARM"
zip "$RELEASE_OSX".zip "$RELEASE_OSX"
- name: Create Release
id: create_release
uses: monkeyWie/create-release@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: true
- name: Upload Release - Windows 64bit
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./${{ env.RELEASE_WIN64 }}.zip
asset_name: ${{ env.RELEASE_WIN64 }}.zip
asset_content_type: application/zip
- name: Upload Release - Windows 32bit
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./${{ env.RELEASE_WIN32 }}.zip
asset_name: ${{ env.RELEASE_WIN32 }}.zip
asset_content_type: application/zip
- name: Upload Release - Linux amd64
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./${{ env.RELEASE_LinuxAMD64 }}.zip
asset_name: ${{ env.RELEASE_LinuxAMD64 }}.zip
asset_content_type: application/zip
- name: Upload Release - Linux 386
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./${{ env.RELEASE_Linux386 }}.zip
asset_name: ${{ env.RELEASE_Linux386 }}.zip
asset_content_type: application/zip
- name: Upload Release - Linux arm64
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./${{ env.RELEASE_LinuxARM64 }}.zip
asset_name: ${{ env.RELEASE_LinuxARM64 }}.zip
asset_content_type: application/zip
- name: Upload Release - Linux arm
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./${{ env.RELEASE_LinuxARM }}.zip
asset_name: ${{ env.RELEASE_LinuxARM }}.zip
asset_content_type: application/zip
- name: Upload Release - Darwin amd64
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./${{ env.RELEASE_OSX }}.zip
asset_name: ${{ env.RELEASE_OSX }}.zip
asset_content_type: application/zip

Loading…
Cancel
Save