Release #41
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
name: Release | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Version of zbox to release' | |
required: true | |
default: '1.0.0' | |
tag: | |
description: 'Tag of zbox to release' | |
required: true | |
default: 'v1.0.0' | |
draft: | |
description: 'Create release as draft' | |
required: false | |
default: 'true' | |
prerelease: | |
description: 'Create release as prerelease' | |
required: false | |
default: 'false' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GOSDK }} | |
VERSION: ${{ github.event.inputs.version }} | |
APP_NAME: zbox | |
GO_VERSION: 1.21 | |
jobs: | |
create_release: | |
runs-on: ubuntu-latest | |
outputs: | |
release_id: ${{ steps.create_release.outputs.id }} | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
steps: | |
- name: Create GitHub Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.event.inputs.tag }} | |
release_name: ${{ github.event.inputs.tag }} | |
draft: ${{ github.event.inputs.draft }} | |
prerelease: ${{ github.event.inputs.prerelease }} | |
linux: | |
runs-on: ubuntu-latest | |
needs: create_release | |
env: | |
SRC_DIR: ${{ github.workspace }}/src | |
OUTPUT_DIR: ${{ github.workspace }}/output | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
path: ${{ env.SRC_DIR }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: linux/amd64,linux/arm64 | |
- name: Install zip | |
uses: montudor/action-zip@v1 | |
- name: Setup | |
run : | | |
mkdir -p ${{ env.OUTPUT_DIR }} | |
cp ${{ env.SRC_DIR }}/cmd/config.yaml ${{ env.OUTPUT_DIR }} | |
- name: Build Docker image for linux/amd64 | |
run: | | |
docker buildx create --use | |
docker buildx build \ | |
--platform linux/amd64 \ | |
--build-arg VERSION=${{ env.VERSION }} \ | |
--tag ${{ env.APP_NAME }}-amd64 \ | |
--load \ | |
--output type=docker,dest=${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }}-amd64.tar \ | |
-f ${{ env.SRC_DIR }}/scripts/debian/Dockerfile.build ${{ env.SRC_DIR }} | |
- name: Load image ${{ env.APP_NAME }}-amd64 & Extract binary ${{ env.APP_NAME }} from container | |
run: | | |
docker load -i ${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }}-amd64.tar | |
CONTAINER_ID=$(docker create ${{ env.APP_NAME }}-amd64) | |
docker cp ${CONTAINER_ID}:/zbox ${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }} | |
docker rm ${CONTAINER_ID} | |
- name: Create Zip File for linux/amd64 | |
run: | | |
cd ${{ env.OUTPUT_DIR }} | |
zip -qq -r ${{ env.APP_NAME }}-linux-amd64.zip ${{ env.APP_NAME }} config.yaml | |
- name: Upload Zip for linux/amd64 | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.APP_NAME }}-linux-amd64 | |
path: ${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }}-linux-amd64.zip | |
- name: Build Docker image for linux/arm64 | |
run: | | |
docker buildx create --use | |
docker buildx build \ | |
--platform linux/arm64 \ | |
--build-arg VERSION=${{ env.VERSION }} \ | |
--tag ${{ env.APP_NAME }}-arm64 \ | |
--load \ | |
--output type=docker,dest=${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }}-arm64.tar \ | |
-f ${{ env.SRC_DIR }}/scripts/debian/Dockerfile.build ${{ env.SRC_DIR }} | |
- name: Load image ${{ env.APP_NAME }}-arm64 & Extract binary from container | |
run: | | |
docker load -i ${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }}-arm64.tar | |
CONTAINER_ID=$(docker create ${{ env.APP_NAME }}-arm64) | |
docker cp ${CONTAINER_ID}:/zbox ${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }} | |
docker rm ${CONTAINER_ID} | |
- name: Create Zip File for linux/arm64 | |
run: | | |
cd ${{ env.OUTPUT_DIR }} | |
zip -qq -r ${{ env.APP_NAME }}-linux-arm64.zip ${{ env.APP_NAME }} config.yaml | |
- name: Upload Zip for linux/arm64 | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.APP_NAME }}-linux-arm64 | |
path: ${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }}-linux-arm64.zip | |
- name: Upload Release Asset for Linux/amd64 | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.create_release.outputs.upload_url }} | |
asset_path: ${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }}-linux-amd64.zip | |
asset_name: ${{ env.APP_NAME }}-linux-amd64.zip | |
asset_content_type: application/zip | |
- name: Upload Release Asset for Linux/arm64 | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.create_release.outputs.upload_url }} | |
asset_path: ${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }}-linux-arm64.zip | |
asset_name: ${{ env.APP_NAME }}-linux-arm64.zip | |
asset_content_type: application/zip | |
darwin: | |
runs-on: macos-latest | |
needs: create_release | |
env: | |
SRC_DIR: ${{ github.workspace }}/src | |
OUTPUT_DIR: ${{ github.workspace }}/output | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
path: ${{ env.SRC_DIR }} | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Setup | |
run : | | |
mkdir -p ${{ env.OUTPUT_DIR }}/amd64 | |
mkdir -p ${{ env.OUTPUT_DIR }}/arm64 | |
cp ${{ env.SRC_DIR }}/cmd/config.yaml ${{ env.OUTPUT_DIR }}/amd64/ | |
cp ${{ env.SRC_DIR }}/cmd/config.yaml ${{ env.OUTPUT_DIR }}/arm64/ | |
- name: Build ${{ env.APP_NAME }} for arm64 | |
run: | | |
cd ${{ env.SRC_DIR }} | |
CGO_ENABLED=1 CGO_CFLAGS="-mmacosx-version-min=12.0" CGO_LDFLAGS="-mmacosx-version-min=12.0" GOOS=darwin GOARCH=arm64 SDKROOT=$(xcrun --sdk macosx --show-sdk-path) go build -x -v -tags bn256 -ldflags "-X main.VersionStr=v${{ env.VERSION }}" -o ${{ env.OUTPUT_DIR }}/arm64/${{ env.APP_NAME }} . | |
- name: Build ${{ env.APP_NAME }} for amd64 | |
run: | | |
cd ${{ env.SRC_DIR }} | |
CGO_ENABLED=1 CGO_CFLAGS="-mmacosx-version-min=12.0" CGO_LDFLAGS="-mmacosx-version-min=12.0" GOOS=darwin GOARCH=amd64 SDKROOT=$(xcrun --sdk macosx --show-sdk-path) go build -x -v -tags bn256 -ldflags "-X main.VersionStr=v${{ env.VERSION }}" -o ${{ env.OUTPUT_DIR }}/amd64/${{ env.APP_NAME }} . | |
- name: Create Zip File for darwin/amd64 | |
run: | | |
cd ${{ env.OUTPUT_DIR }}/amd64 | |
zip -qq -r ${{ env.APP_NAME }}-darwin-amd64.zip ${{ env.APP_NAME }} config.yaml | |
- name: Upload Zip for Darwin/amd64 | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.APP_NAME }}-darwin-amd64 | |
path: ${{ env.OUTPUT_DIR }}/amd64/${{ env.APP_NAME }}-darwin-amd64.zip | |
- name: Create Zip File for darwin/arm64 | |
run: | | |
cd ${{ env.OUTPUT_DIR }}/arm64 | |
zip -qq -r ${{ env.APP_NAME }}-darwin-arm64.zip ${{ env.APP_NAME }} config.yaml | |
- name: Upload Zip for Darwin/arm64 | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.APP_NAME }}-darwin-arm64 | |
path: ${{ env.OUTPUT_DIR }}/arm64/${{ env.APP_NAME }}-darwin-arm64.zip | |
- name: Upload Release Asset for Darwin/amd64 | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.create_release.outputs.upload_url }} | |
asset_path: ${{ env.OUTPUT_DIR }}/amd64/${{ env.APP_NAME }}-darwin-amd64.zip | |
asset_name: ${{ env.APP_NAME }}-darwin-amd64.zip | |
asset_content_type: application/zip | |
- name: Upload Release Asset for Darwin/arm64 | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.create_release.outputs.upload_url }} | |
asset_path: ${{ env.OUTPUT_DIR }}/arm64/${{ env.APP_NAME }}-darwin-arm64.zip | |
asset_name: ${{ env.APP_NAME }}-darwin-arm64.zip | |
asset_content_type: application/zip | |
windows: | |
runs-on: windows-latest | |
needs: create_release | |
env: | |
SRC_DIR: ${{ github.workspace }}\src | |
OUTPUT_DIR: ${{ github.workspace }}\output | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
path: ${{ env.SRC_DIR }} | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Install MinGW for CGo | |
run: | | |
choco install mingw | |
- name: Setup | |
run : | | |
New-Item -ItemType Directory -Force -Path "${{ env.OUTPUT_DIR }}\amd64" | |
Copy-Item -Force -Path "${{ env.SRC_DIR }}\cmd\config.yaml" -Destination "${{ env.OUTPUT_DIR }}\amd64\" | |
- name: Build ${{ env.APP_NAME }} for amd64 | |
run: | | |
Set-Location -Path "${{ env.SRC_DIR }}" | |
$env:CGO_ENABLED="1" | |
$env:CC="x86_64-w64-mingw32-gcc" | |
$env:CXX="x86_64-w64-mingw32-g++" | |
$env:GOOS="windows" | |
$env:GOARCH="amd64" | |
where x86_64-w64-mingw32-gcc | |
where x86_64-w64-mingw32-g++ | |
go build -x -v -tags bn256 -ldflags "-X main.VersionStr=v${{ env.VERSION }}" -o ${{ env.OUTPUT_DIR }}\amd64\${{ env.APP_NAME }}.exe . | |
shell: pwsh | |
- name: Create Zip File for windows/amd64 | |
run: | | |
Set-Location -Path "${{ env.OUTPUT_DIR }}\amd64" | |
Compress-Archive -Path @("${{ env.APP_NAME }}.exe", "config.yaml") -DestinationPath ${{ env.APP_NAME }}-windows-amd64.zip | |
- name: Upload Zip for windows/amd64 | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.APP_NAME }}-windows-amd64 | |
path: ${{ env.OUTPUT_DIR }}\amd64\${{ env.APP_NAME }}-windows-amd64.zip | |
- name: Upload Release Asset for windows/amd64 | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.create_release.outputs.upload_url }} | |
asset_path: ${{ env.OUTPUT_DIR }}\amd64\${{ env.APP_NAME }}-windows-amd64.zip | |
asset_name: ${{ env.APP_NAME }}-windows-amd64.zip | |
asset_content_type: application/zip | |