mirror of
https://git.unlock-music.dev/um/cli.git
synced 2025-05-23 00:26:19 +08:00
build: get ci working again
This commit is contained in:
parent
006bad8c48
commit
05e5783336
108
.gitea/workflows/build.yml
Normal file
108
.gitea/workflows/build.yml
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
name: Build
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
- "**/*.go"
|
||||||
|
- "go.mod"
|
||||||
|
- "go.sum"
|
||||||
|
- ".gitea/workflows/*.yml"
|
||||||
|
pull_request:
|
||||||
|
branches: [ main ]
|
||||||
|
types: [ opened, synchronize, reopened ]
|
||||||
|
paths:
|
||||||
|
- "**/*.go"
|
||||||
|
- "go.mod"
|
||||||
|
- "go.sum"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
GOOS:
|
||||||
|
- linux
|
||||||
|
- windows
|
||||||
|
- darwin
|
||||||
|
GOARCH:
|
||||||
|
- "amd64"
|
||||||
|
- "386"
|
||||||
|
- "arm64"
|
||||||
|
|
||||||
|
exclude:
|
||||||
|
- GOOS: darwin
|
||||||
|
GOARCH: "386"
|
||||||
|
|
||||||
|
include:
|
||||||
|
- GOOS: windows
|
||||||
|
BIN_SUFFIX: ".exe"
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout codebase
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Set up Go 1.23
|
||||||
|
uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: ^1.23
|
||||||
|
|
||||||
|
- name: Setup vars
|
||||||
|
id: vars
|
||||||
|
run: |
|
||||||
|
echo "::set-output name=short_sha::$(git rev-parse --short HEAD)"
|
||||||
|
echo "::set-output name=git_tag::$(git describe --tags --always)"
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: go test -v ./...
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
env:
|
||||||
|
GOOS: ${{ matrix.GOOS }}
|
||||||
|
GOARCH: ${{ matrix.GOARCH }}
|
||||||
|
CGO_ENABLED: 0
|
||||||
|
run: go build -v -trimpath -ldflags="-w -s -X main.AppVersion=${{ steps.vars.outputs.git_tag }}" -o um-${{ matrix.GOOS }}-${{ matrix.GOARCH }}${{ matrix.BIN_SUFFIX }} ./cmd/um
|
||||||
|
|
||||||
|
- name: Publish artifact
|
||||||
|
uses: christopherhx/gitea-upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: um-${{ matrix.GOOS }}-${{ matrix.GOARCH }}
|
||||||
|
path: ./um-${{ matrix.GOOS }}-${{ matrix.GOARCH }}${{ matrix.BIN_SUFFIX }}
|
||||||
|
|
||||||
|
archive:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: build
|
||||||
|
steps:
|
||||||
|
- name: prepare archive
|
||||||
|
run: |
|
||||||
|
mkdir -p dist prepare
|
||||||
|
- name: Download artifacts
|
||||||
|
uses: christopherhx/gitea-download-artifact@v4
|
||||||
|
with:
|
||||||
|
path: prepare
|
||||||
|
pattern: um-*
|
||||||
|
- name: prepare archive
|
||||||
|
run: |
|
||||||
|
for exe in prepare/*/um-*.exe; do
|
||||||
|
zip -9 -j "dist/$(basename "$exe" .exe).zip" "$exe"
|
||||||
|
rm -f "$exe"
|
||||||
|
done
|
||||||
|
for exe in prepare/*/um-*; do
|
||||||
|
tar \
|
||||||
|
--sort=name --format=posix \
|
||||||
|
--pax-option=exthdr.name=%d/PaxHeaders/%f \
|
||||||
|
--pax-option=delete=atime,delete=ctime \
|
||||||
|
--clamp-mtime --mtime='1970-01-01T00:00:00Z' \
|
||||||
|
--numeric-owner --owner=0 --group=0 \
|
||||||
|
--mode=0755 \
|
||||||
|
-cv \
|
||||||
|
-C "$(dirname "$exe")" \
|
||||||
|
"$(basename "$exe")" \
|
||||||
|
| gzip -9 > "dist/$(basename "$exe").tar.gz"
|
||||||
|
rm -f "$exe"
|
||||||
|
done
|
||||||
|
- name: Publish all-in-one archive
|
||||||
|
uses: christopherhx/gitea-upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: dist-all
|
||||||
|
path: dist
|
67
.github/workflows/build.yml
vendored
67
.github/workflows/build.yml
vendored
@ -1,67 +0,0 @@
|
|||||||
name: Build
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
paths:
|
|
||||||
- "**/*.go"
|
|
||||||
- "go.mod"
|
|
||||||
- "go.sum"
|
|
||||||
- ".github/workflows/*.yml"
|
|
||||||
pull_request:
|
|
||||||
branches: [ master ]
|
|
||||||
types: [ opened, synchronize, reopened ]
|
|
||||||
paths:
|
|
||||||
- "**/*.go"
|
|
||||||
- "go.mod"
|
|
||||||
- "go.sum"
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
test:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- target: "linux/amd64"
|
|
||||||
GOOS: "linux"
|
|
||||||
GOARCH: "amd64"
|
|
||||||
BIN_SUFFIX: ""
|
|
||||||
- target: "windows/amd64"
|
|
||||||
GOOS: "windows"
|
|
||||||
GOARCH: "amd64"
|
|
||||||
BIN_SUFFIX: ".exe"
|
|
||||||
- target: "darwin/amd64"
|
|
||||||
GOOS: "darwin"
|
|
||||||
GOARCH: "amd64"
|
|
||||||
BIN_SUFFIX: ""
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout codebase
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Set up Go 1.x
|
|
||||||
uses: actions/setup-go@v2
|
|
||||||
with:
|
|
||||||
go-version: ^1.17
|
|
||||||
|
|
||||||
- name: Setup vars
|
|
||||||
id: vars
|
|
||||||
run: |
|
|
||||||
echo "::set-output name=short_sha::$(git rev-parse --short HEAD)"
|
|
||||||
echo "::set-output name=git_tag::$(git describe --tags --always)"
|
|
||||||
|
|
||||||
- name: Test
|
|
||||||
run: go test -v ./...
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
env:
|
|
||||||
GOOS: ${{ matrix.GOOS }}
|
|
||||||
GOARCH: ${{ matrix.GOARCH }}
|
|
||||||
CGO_ENABLED: 0
|
|
||||||
run: go build -v -trimpath -ldflags="-w -s -X main.AppVersion=${{ steps.vars.outputs.git_tag }}" -o um-${{ matrix.GOOS }}-${{ matrix.GOARCH }}${{ matrix.BIN_SUFFIX }} ./cmd/um
|
|
||||||
|
|
||||||
- name: Publish artifact
|
|
||||||
uses: actions/upload-artifact@v2
|
|
||||||
with:
|
|
||||||
name: um-${{ matrix.GOOS }}-${{ matrix.GOARCH }}
|
|
||||||
path: ./um-${{ matrix.GOOS }}-${{ matrix.GOARCH }}${{ matrix.BIN_SUFFIX }}
|
|
84
.github/workflows/release.yml
vendored
84
.github/workflows/release.yml
vendored
@ -1,84 +0,0 @@
|
|||||||
name: Create Release
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- "v*"
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
create_release:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Get current time
|
|
||||||
id: date
|
|
||||||
run: echo "::set-output name=date::$(date +'%Y/%m/%d')"
|
|
||||||
|
|
||||||
- name: Create release
|
|
||||||
id: release
|
|
||||||
uses: actions/create-release@v1
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
tag_name: ${{ github.ref }}
|
|
||||||
release_name: "Build ${{ steps.date.outputs.date }}"
|
|
||||||
draft: true
|
|
||||||
outputs:
|
|
||||||
upload_url: "${{ steps.release.outputs.upload_url }}"
|
|
||||||
build:
|
|
||||||
needs:
|
|
||||||
- create_release
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- target: "linux/amd64"
|
|
||||||
GOOS: "linux"
|
|
||||||
GOARCH: "amd64"
|
|
||||||
BIN_SUFFIX: ""
|
|
||||||
- target: "windows/amd64"
|
|
||||||
GOOS: "windows"
|
|
||||||
GOARCH: "amd64"
|
|
||||||
BIN_SUFFIX: ".exe"
|
|
||||||
- target: "windows/386"
|
|
||||||
GOOS: "windows"
|
|
||||||
GOARCH: "386"
|
|
||||||
BIN_SUFFIX: ".exe"
|
|
||||||
- target: "darwin/amd64"
|
|
||||||
GOOS: "darwin"
|
|
||||||
GOARCH: "amd64"
|
|
||||||
BIN_SUFFIX: ""
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout codebase
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Setup vars
|
|
||||||
id: vars
|
|
||||||
run: |
|
|
||||||
echo "::set-output name=short_sha::$(git rev-parse --short HEAD)"
|
|
||||||
echo "::set-output name=git_tag::$(git describe --tags --always)"
|
|
||||||
|
|
||||||
- name: Set up Go 1.x
|
|
||||||
uses: actions/setup-go@v2
|
|
||||||
with:
|
|
||||||
go-version: ^1.17
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
env:
|
|
||||||
GOOS: ${{ matrix.GOOS }}
|
|
||||||
GOARCH: ${{ matrix.GOARCH }}
|
|
||||||
CGO_ENABLED: 0
|
|
||||||
run: go build -trimpath -v -ldflags="-w -s -X main.AppVersion=${{ steps.vars.outputs.git_tag }}" -o um ./cmd/um
|
|
||||||
|
|
||||||
- name: Upload release assets
|
|
||||||
uses: actions/upload-release-asset@v1
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
upload_url: ${{ needs.create_release.outputs.upload_url }}
|
|
||||||
asset_path: um
|
|
||||||
asset_name: um-${{ matrix.GOOS }}-${{ matrix.GOARCH }}${{ matrix.BIN_SUFFIX }}
|
|
||||||
asset_content_type: application/octet-stream
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user