Skip to content

Commit

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

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

jobs:
release:
name: Release wpex ${{ github.ref_name }}
runs-on: ubuntu-latest

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
26 changes: 26 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Tests

on:
push:
pull_request:

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 f456049

Please sign in to comment.