From 76773e0d3dd0f94e66fa06aa9fc173de5cf089e2 Mon Sep 17 00:00:00 2001 From: k3y0708 Date: Tue, 9 May 2023 21:55:54 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20Add=20release=20CI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 5 +++ Makefile | 38 ++++++++++++++++++ workflows/Release.yml | 90 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 133 insertions(+) create mode 100644 CHANGELOG.md create mode 100644 workflows/Release.yml diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..ece05cc --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +# Changelog + +# v0.0.1 + +- Initial release diff --git a/Makefile b/Makefile index 1b9aec1..4b7917d 100644 --- a/Makefile +++ b/Makefile @@ -7,3 +7,41 @@ compile: @cd src && \ go build -o ../build/otter && \ cd .. + +compile_windows_64: + @echo "Compiling for Windows 64..." + @cd src && \ + GOOS=windows GOARCH=amd64 go build -o ../build/otter-amd64.exe && \ + cd .. + +compile_windows_32: + @echo "Compiling for Windows 32..." + @cd src && \ + GOOS=windows GOARCH=386 go build -o ../build/otter-386.exe && \ + cd .. + +compile_linux_64: + @echo "Compiling for Linux 64..." + @cd src && \ + GOOS=linux GOARCH=amd64 go build -o ../build/otter-linux-amd64 && \ + cd .. + +compile_linux_32: + @echo "Compiling for Linux 32..." + @cd src && \ + GOOS=linux GOARCH=386 go build -o ../build/otter-linux-386 && \ + cd .. + +compile_mac_64: + @echo "Compiling for Mac 64..." + @cd src && \ + GOOS=darwin GOARCH=amd64 go build -o ../build/otter-mac-amd64 && \ + cd .. + +compile_mac_arm: + @echo "Compiling for Mac ARM..." + @cd src && \ + GOOS=darwin GOARCH=arm64 go build -o ../build/otter-mac-arm64 && \ + cd .. + +compile_all: compile_windows_32 compile_windows_64 compile_linux_32 compile_linux_64 compile_mac_64 compile_mac_arm diff --git a/workflows/Release.yml b/workflows/Release.yml new file mode 100644 index 0000000..71b72dd --- /dev/null +++ b/workflows/Release.yml @@ -0,0 +1,90 @@ +name: release + +on: + push: + tags: + - "v*" + +jobs: + build_release: + name: build_release + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: build artifacts + run: make compile + shell: bash + - name: version + run: echo "::set-output name=version::$(./otter version)" + id: version + - name: build artifacts + run: make deploy_all + shell: bash + - name: release + uses: actions/create-release@v1 + id: create_release + with: + draft: false + prerelease: false + release_name: ${{ steps.version.outputs.version }} + tag_name: ${{ github.ref }} + body_path: CHANGELOG.md + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} + - name: upload windows64 artifact + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./out/otter-amd64.exe + asset_name: otter-amd64.exe + asset_content_type: application/x-dosexec + - name: upload windows32 artifact + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./out/otter-386.exe + asset_name: otter-386.exe + asset_content_type: application/x-dosexec + - name: upload linux64 artifact + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./out/otter-linux-amd64 + asset_name: otter-linux-amd64 + asset_content_type: application/x-executable + - name: upload linux32 artifact + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./out/otter-linux-386 + asset_name: otter-linux-386 + asset_content_type: application/x-executable + - name: upload mac intel64 artifact + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./out/otter-mac-amd64 + asset_name: otter-mac-amd64 + asset_content_type: application/x-mach-binary + - name: upload mac arm64 artifact + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./out/otter-mac-arm64 + asset_name: otter-mac-arm64 + asset_content_type: application/x-mach-binary