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. 246
      .github/workflows/release.yml

@ -5,140 +5,134 @@ on:
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: steps:
- name: Set up Go - name: Checkout source
uses: actions/setup-go@v2 uses: actions/checkout@v1
- name: Use Golang
uses: actions/setup-go@v1
with:
go-version: "1.15"
-
name: Build with xgo
uses: crazy-max/ghaction-xgo@v1
with: with:
go-version: 1.15 xgo_version: latest
- if: matrix.os == 'ubuntu-latest' go_version: ${{ matrix.go_version }}
run: sudo apt-get update && sudo apt-get install -y gcc-multilib dest: build
- if: matrix.arch == '386' prefix: hack-browser-data
run: echo "RELEASE=hack-browser-data-${{ github.event.release.tag_name}}-${{ matrix.releaseos}}-32bit" >> $GITHUB_ENV targets: windows/amd64,windows/386,linux/386,linux/amd64,linux/arm,linux/arm64,darwin/amd64
- if: matrix.arch == 'amd64' v: true
run: echo "RELEASE=hack-browser-data-${{ github.event.release.tag_name}}-${{ matrix.releaseos}}-64bit" >> $GITHUB_ENV x: false
- if: matrix.os == 'windows-latest' race: false
shell: powershell ldflags: -s -w
run: echo "RELEASE=hack-browser-data-${{ github.event.release.tag_name}}-${{ matrix.releaseos}}-64bit" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append buildmode: default
- uses: actions/checkout@v2
- name: Build ${{ matrix.goos }}/${{ matrix.arch }} - name: Set Variable
run: go build -ldflags '-w -s' -o ${{ matrix.bin }} run: |
echo "RELEASE_WIN32=hack-browser-data-${{ github.event.release.tag_name}}windows-32bit" >> $GITHUB_ENV
echo "RELEASE_WIN64=hack-browser-data-${{ github.event.release.tag_name}}windows-64bit" >> $GITHUB_ENV
echo "RELEASE_OSX=hack-browser-data-${{ github.event.release.tag_name}}osx-64bit" >> $GITHUB_ENV
echo "RELEASE_Linux386=hack-browser-data-${{ github.event.release.tag_name}}linux-386" >> $GITHUB_ENV
echo "RELEASE_LinuxARM64=hack-browser-data-${{ github.event.release.tag_name}}linux-arm64" >> $GITHUB_ENV
echo "RELEASE_LinuxAMD64=hack-browser-data-${{ github.event.release.tag_name}}linux-amd64" >> $GITHUB_ENV
echo "RELEASE_LinuxARM=hack-browser-data-${{ github.event.release.tag_name}}linux-arm" >> $GITHUB_ENV
- name: Build zip
run: |
mv build/hack-browser-data-windows*386.exe "$RELEASE_WIN32".exe
mv build/hack-browser-data-windows*amd64.exe "$RELEASE_WIN64".exe
mv build/hack-browser-data-linux-*386 "$RELEASE_Linux386"
mv build/hack-browser-data-linux-*amd64 "$RELEASE_LinuxAMD64"
mv build/hack-browser-data-linux-*arm64 "$RELEASE_LinuxARM64"
mv build/hack-browser-data-linux-*arm-* "$RELEASE_LinuxARM"
mv build/hack-browser-data-darwin-*amd64 "$RELEASE_OSX"
zip "$RELEASE_WIN32".zip "$RELEASE_WIN32".exe
zip "$RELEASE_WIN64".zip "$RELEASE_WIN64".exe
zip "$RELEASE_Linux386".zip "$RELEASE_Linux386"
zip "$RELEASE_LinuxAMD64".zip "$RELEASE_LinuxAMD64"
zip "$RELEASE_LinuxARM64".zip "$RELEASE_Linux386"
zip "$RELEASE_LinuxARM".zip "$RELEASE_LinuxARM"
zip "$RELEASE_OSX".zip "$RELEASE_OSX"
- name: Create Release
id: create_release
uses: monkeyWie/create-release@master
env: env:
GOOS: ${{ matrix.goos }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GOARCH: ${{ matrix.arch }}
CGO_ENABLED: 1
- uses: svenstaro/upx-action@v2
with: with:
args: ${{ matrix.args }} tag_name: ${{ github.ref }}
file: ${{ matrix.bin }} release_name: Release ${{ github.ref }}
- name: Upload to artifacts draft: false
uses: actions/upload-artifact@v2 prerelease: true
- name: Upload Release - Windows 64bit
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
name: ${{ env.RELEASE }} 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
path: ${{ matrix.bin }} asset_path: ./${{ env.RELEASE_WIN64 }}.zip
package: asset_name: ${{ env.RELEASE_WIN64 }}.zip
name: Package Assets asset_content_type: application/zip
runs-on: ubuntu-latest
needs: build - name: Upload Release - Windows 32bit
steps: uses: actions/upload-release-asset@v1.0.1
- uses: actions/checkout@v2 env:
- uses: actions/download-artifact@v2 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
path: bin 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
- name: Package Releases asset_path: ./${{ env.RELEASE_WIN32 }}.zip
run: | asset_name: ${{ env.RELEASE_WIN32 }}.zip
mkdir releases; asset_content_type: application/zip
for RELEASE_DIR in bin/*
do - name: Upload Release - Linux amd64
echo "Creating release $RELEASE_DIR" uses: actions/upload-release-asset@v1.0.1
for BINARY in $RELEASE_DIR/* env:
do GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
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: with:
name: releases 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
path: releases/*.zip asset_path: ./${{ env.RELEASE_LinuxAMD64 }}.zip
asset_name: ${{ env.RELEASE_LinuxAMD64 }}.zip
asset_content_type: application/zip
upload: - name: Upload Release - Linux 386
name: Upload to the Release uses: actions/upload-release-asset@v1.0.1
runs-on: ubuntu-latest env:
needs: package GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/download-artifact@v2
with: with:
name: releases 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
path: releases/ asset_path: ./${{ env.RELEASE_Linux386 }}.zip
- name: Upload Archives to Release 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: env:
UPLOAD_URL: ${{ github.event.release.upload_url }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
API_HEADER: "Accept: application/vnd.github.v3+json" with:
AUTH_HEADER: "Authorization: token ${{ secrets.GITHUB_TOKEN }}" 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
run: | asset_path: ./${{ env.RELEASE_LinuxARM64 }}.zip
UPLOAD_URL=$(echo -n $UPLOAD_URL | sed s/\{.*//g) asset_name: ${{ env.RELEASE_LinuxARM64 }}.zip
for FILE in releases/* asset_content_type: application/zip
do
echo "Uploading ${FILE}"; - name: Upload Release - Linux arm
curl \ uses: actions/upload-release-asset@v1.0.1
-H "${API_HEADER}" \
-H "${AUTH_HEADER}" \
-H "Content-Type: $(file -b --mime-type ${FILE})" \
--data-binary "@${FILE}" \
"${UPLOAD_URL}?name=$(basename ${FILE})";
done
- name: Generate SHA256 Hashes
env: env:
API_HEADER: "Accept: application/vnd.github.v3+json" GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AUTH_HEADER: "Authorization: token ${{ secrets.GITHUB_TOKEN }}" with:
RELEASE_URL: ${{ github.event.release.url }} 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
run: | asset_path: ./${{ env.RELEASE_LinuxARM }}.zip
HASH_TABLE="| SHA256 Hash | Filename |" asset_name: ${{ env.RELEASE_LinuxARM }}.zip
HASH_TABLE="${HASH_TABLE}\n|-----|-----|\n" asset_content_type: application/zip
for FILE in releases/*
do - name: Upload Release - Darwin amd64
FILENAME=$(basename ${FILE}) uses: actions/upload-release-asset@v1.0.1
HASH=$(sha256sum ${FILE} | cut -d ' ' -f 1) env:
HASH_TABLE="${HASH_TABLE}|${HASH}|${FILENAME}|\n" GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
done with:
echo "${HASH_TABLE}" 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
curl \ asset_path: ./${{ env.RELEASE_OSX }}.zip
-XPATCH \ asset_name: ${{ env.RELEASE_OSX }}.zip
-H "${API_HEADER}" \ asset_content_type: application/zip
-H "${AUTH_HEADER}" \
-H "Content-Type: application/json" \
-d "{\"body\": \"${HASH_TABLE}\"}" \
"${RELEASE_URL}";

Loading…
Cancel
Save