Skip to content

Commit

Permalink
Create build&release.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
hexahigh authored Oct 30, 2023
1 parent 45d1759 commit 58f2ade
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/build&release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Build and Pre-release

on:
workflow_dispatch:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
outputs:
asset_paths: "dht-dce-windows-386,dht-dce-windows-amd64,dht-dce-linux-386,dht-dce-linux-amd64"
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.20.6

- name: Check out code
uses: actions/checkout@v2

- name: Get dependencies
run: go get -v -t -d ./...

- name: Build windows-386
run: GOOS=windows GOARCH=386 go build -v -o dht-dce-windows-386.exe .

- name: Build windows-amd64
run: GOOS=windows GOARCH=amd64 go build -v -o dht-dce-windows-amd64.exe .

- name: Build linux-386
run: GOOS=linux GOARCH=386 go build -v -o dht-dce-linux-386 .

- name: Build linux-amd64
run: GOOS=linux GOARCH=amd64 go build -v -o dht-dce-linux-amd64 .

- name: Upload the artifact
uses: actions/upload-artifact@v3
with:
name: build
path: |
dht-dce-windows-386.exe
dht-dce-windows-amd64.exe
dht-dce-linux-386
dht-dce-linux-amd64
upload:
name: Upload release
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/main'

steps:
- name: Delete old release and tag
uses: dev-drprasad/[email protected]
with:
delete_release: true
tag_name: latest_auto
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Get artifacts
uses: actions/download-artifact@v3
with:
path: build

- name: Release to GitHub
uses: ncipollo/release-action@v1
with:
name: Latest Autobuild
tag: latest_auto
commit: main
body: ${{ github.event.head_commit.message }}
artifacts: "build/dht-dce/dht-dce-windows-386.exe, build/dht-dce/dht-dce-windows-amd64.exe, build/dht-dce/dht-dce-linux-386, build/dht-dce/dht-dce-linux-amd64"
prerelease: true

0 comments on commit 58f2ade

Please sign in to comment.