-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
179 additions
and
87 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,64 @@ | ||
name: GoBuild | ||
# This workflow will build a golang project | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go | ||
|
||
name: Build | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- v* | ||
- release/* | ||
|
||
pull_request: | ||
branches: | ||
- main | ||
- develop/* | ||
- release/* | ||
|
||
jobs: | ||
env: | ||
CLOUDCAT_PREFIX: "cloudcat_" | ||
BINARY_SUFFIX: "" | ||
CCATCTL_PREFIX: "ccatctl_" | ||
COMMIT_ID: "${{ github.sha }}" | ||
|
||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
# build and publish in parallel: linux/386, linux/amd64, windows/386, windows/amd64, darwin/amd64, darwin/arm64 | ||
goos: [linux, windows, darwin] | ||
goarch: ["386", amd64, arm, arm64] | ||
exclude: | ||
- goos: darwin | ||
goarch: arm | ||
- goos: darwin | ||
goarch: "386" | ||
fail-fast: true | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/.cache/go-build | ||
~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: 1.16 | ||
go-version: '1.21' | ||
|
||
- name: Test | ||
run: go test -v ./... | ||
- name: Build binary file | ||
env: | ||
GOOS: ${{ matrix.goos }} | ||
GOARCH: ${{ matrix.goarch }} | ||
run: | | ||
if [ $GOOS = "windows" ]; then export BINARY_SUFFIX="$BINARY_SUFFIX.exe"; fi | ||
export BINARY_NAME="$CLOUDCAT_PREFIX"$GOOS"_$GOARCH$BINARY_SUFFIX" | ||
export CGO_ENABLED=0 | ||
export LD_FLAGS="-w -s -X github.com/scriptscat/cloudcat/configs.Version=${COMMIT_ID::7}" | ||
go build -o "bin/$BINARY_NAME" -trimpath -ldflags "$LD_FLAGS" ./cmd/cloudcat | ||
- name: Build | ||
run: make target | ||
export BINARY_NAME="$CCATCTL_PREFIX"$GOOS"_$GOARCH$BINARY_SUFFIX" | ||
go build -o "bin/$BINARY_NAME" -trimpath -ldflags "$LD_FLAGS" ./cmd/ccatctl | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ matrix.goos }}_${{ matrix.goarch }} | ||
path: bin/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,107 @@ | ||
name: release | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
- 'v*' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
env: | ||
CLOUDCAT_PREFIX: "cloudcat_" | ||
BINARY_SUFFIX: "" | ||
CCATCTL_PREFIX: "ccatctl_" | ||
COMMIT_ID: "${{ github.sha }}" | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
# build and publish in parallel: linux/386, linux/amd64, windows/386, windows/amd64, darwin/amd64, darwin/arm64 | ||
goos: [linux, windows, darwin] | ||
goarch: ["386", amd64, arm, arm64] | ||
exclude: | ||
- goos: darwin | ||
goarch: arm | ||
- goos: darwin | ||
goarch: "386" | ||
fail-fast: true | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/.cache/go-build | ||
~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.16 | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.21' | ||
|
||
- name: Test | ||
run: go test -v ./... | ||
- name: Lint | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
version: latest | ||
|
||
- name: Build | ||
run: make target | ||
- name: Tests | ||
run: | | ||
go test $(go list ./...) | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Login to DockerHub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- name: Build binary file | ||
env: | ||
GOOS: ${{ matrix.goos }} | ||
GOARCH: ${{ matrix.goarch }} | ||
run: | | ||
if [ $GOOS = "windows" ]; then export BINARY_SUFFIX="$BINARY_SUFFIX.exe"; fi | ||
export BINARY_NAME="$CLOUDCAT_PREFIX"$GOOS"_$GOARCH$BINARY_SUFFIX" | ||
export CGO_ENABLED=0 | ||
export LD_FLAGS="-w -s -X github.com/scriptscat/cloudcat/configs.Version=${COMMIT_ID::7}" | ||
go build -o "bin/$BINARY_NAME" -trimpath -ldflags "$LD_FLAGS" ./cmd/cloudcat | ||
- name: Get version | ||
id: get_version | ||
run: echo ::set-output name=VERSION::${GITHUB_REF:10} | ||
export BINARY_NAME="$CCATCTL_PREFIX"$GOOS"_$GOARCH$BINARY_SUFFIX" | ||
go build -o "bin/$BINARY_NAME" -trimpath -ldflags "$LD_FLAGS" ./cmd/ccatctl | ||
- name: Build and push | ||
id: docker_build | ||
uses: docker/build-push-action@v2 | ||
with: | ||
push: true | ||
tags: codfrm/cloudcat:${{ steps.get_version.outputs.VERSION }} | ||
- name: Archive production artifacts | ||
env: | ||
GOOS: ${{ matrix.goos }} | ||
GOARCH: ${{ matrix.goarch }} | ||
run: | | ||
if [ "${{ matrix.goos }}" = "windows" ]; then | ||
zip -j "bin/${CLOUDCAT_PREFIX}${GOOS}_${GOARCH}.zip" "bin/"*"${GOOS}_${GOARCH}${BINARY_SUFFIX}" | ||
else | ||
tar czvf "bin/${CLOUDCAT_PREFIX}${GOOS}_${GOARCH}.tar.gz" -C "bin/" *"${GOOS}_${GOARCH}${BINARY_SUFFIX}" | ||
fi | ||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@latest | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: ${{ github.ref }} | ||
body: | | ||
'no description' | ||
draft: false | ||
prerelease: false | ||
- name: Create Release | ||
uses: actions/create-release@latest | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: ${{ github.ref }} | ||
body: | | ||
'no description' | ||
draft: false | ||
prerelease: false | ||
|
||
- name: Build Target | ||
run: | | ||
VERSION=${{ steps.get_version.outputs.VERSION }} GOOS=linux GOARCH=amd64 make target | ||
tar -zcvf cloudcat-${{ steps.get_version.outputs.VERSION }}-linux-amd64.tar.gz cloudcat-${{ steps.get_version.outputs.VERSION }}-linux-amd64 | ||
- name: Upload Release Asset | ||
uses: actions/upload-release-asset@v1 | ||
if: ${{ matrix.goos != 'windows' }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
GOOS: ${{ matrix.goos }} | ||
GOARCH: ${{ matrix.goarch }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./bin/${CLOUDCAT_PREFIX}${GOOS}_${GOARCH}.tar.gz | ||
asset_name: ${CLOUDCAT_PREFIX}${GOOS}_${GOARCH}.tar.gz | ||
asset_content_type: application/gzip | ||
|
||
- name: Upload Release Asset zip | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: cloudcat-${{ steps.get_version.outputs.VERSION }}-linux-amd64.tar.gz | ||
asset_name: cloudcat-${{ steps.get_version.outputs.VERSION }}-linux-amd64.tar.gz | ||
asset_content_type: application/tar+gz | ||
- name: Upload Release Asset | ||
uses: actions/upload-release-asset@v1 | ||
if: ${{ matrix.goos == 'windows' }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
GOOS: ${{ matrix.goos }} | ||
GOARCH: ${{ matrix.goarch }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./bin/${CLOUDCAT_PREFIX}${GOOS}_${GOARCH}.zip | ||
asset_name: ${CLOUDCAT_PREFIX}${GOOS}_${GOARCH}.zip | ||
asset_content_type: application/zip |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# This workflow will build a golang project | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go | ||
|
||
name: Test | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.21' | ||
|
||
- name: Lint | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
version: latest | ||
|
||
- name: Tests | ||
run: | | ||
go test $(go list ./...) |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
package configs | ||
|
||
var Version = "" |