Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
weiiwang01 committed Sep 20, 2023
0 parents commit 3658b0c
Show file tree
Hide file tree
Showing 15 changed files with 1,813 additions and 0 deletions.
108 changes: 108 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: Build and Publish

on:
push:
tags:
- 'v*.*.*'

jobs:
tests:
uses: ./.github/workflows/tests.yaml

release:
name: Release wpex ${{ github.ref_name }}
runs-on: ubuntu-latest
needs: [ tests ]

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Create Release
id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref_name }}
draft: false
prerelease: false

outputs:
upload_url: ${{ steps.create-release.outputs.upload_url }}

docker:
name: Build and Publish Docker Image
runs-on: ubuntu-latest
needs: [ release ]

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository_owner }}/wpex
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v4
with:
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}

binary:
name: Build and Publish Pre-built binaries
runs-on: ubuntu-latest
needs: [ release ]
strategy:
matrix:
GOOS: [ darwin, linux, windows ]
GOARCH: [ 386, amd64, arm64 ]
exclude:
- GOOS: darwin
GOARCH: 386

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Golang
uses: actions/setup-go@v4
with:
go-version: '1.21'

- name: Build wpex
run: CGO_ENABLED=0 GOOS=${{ matrix.GOOS }} GOARCH=${{ matrix.GOARCH }} go build -ldflags="-w -s" -o wpex

- name: Get Version
id: version
run: echo version=${GITHUB_REF##*v} >> $GITHUB_OUTPUT

- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: ./wpex
asset_name: wpex_${{ steps.version.outputs.version }}_${{ matrix.GOOS }}_${{ matrix.GOARCH }}
asset_content_type: application/zip
27 changes: 27 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Tests

on:
push:
pull_request:
workflow_call:

jobs:
test:
name: Run Tests
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]

steps:
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.21

- name: Build and Test
run: |
go test -race ./...
Loading

0 comments on commit 3658b0c

Please sign in to comment.