mirror of
https://git.unlock-music.dev/um/cli.git
synced 2025-05-23 00:26:19 +08:00
ci: cleanup build job, follow old release naming
This commit is contained in:
parent
17cde2a1a5
commit
896ace49fd
148
.drone.jsonnet
148
.drone.jsonnet
@ -1,148 +0,0 @@
|
||||
// generate .drone.yaml, run:
|
||||
// drone jsonnet --format --stream
|
||||
|
||||
|
||||
local CreateRelease() = {
|
||||
name: 'create release',
|
||||
image: 'plugins/gitea-release',
|
||||
settings: {
|
||||
api_key: { from_secret: 'GITEA_API_KEY' },
|
||||
base_url: 'https://git.unlock-music.dev',
|
||||
files: [
|
||||
'um-*.tar.gz',
|
||||
'um-*.zip',
|
||||
],
|
||||
checksum: 'sha256',
|
||||
draft: true,
|
||||
title: '${DRONE_TAG}',
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
local StepGoBuild(GOOS, GOARCH) = {
|
||||
local windows = GOOS == 'windows',
|
||||
local archiveExt = if windows then 'zip' else 'tar.gz',
|
||||
local filepath = 'dist/um-%s-%s-%s.%s' % [GOOS, GOARCH, '$(git describe --tags --always)', archiveExt],
|
||||
|
||||
local archive = if windows then [
|
||||
// Ensure zip is installed
|
||||
'command -v zip >/dev/null || (apt update && apt install -y zip)',
|
||||
'zip -9 -j -r "%s" $DIST_DIR' % filepath,
|
||||
] else [
|
||||
'tar -c -C $DIST_DIR um | gzip -9 > "%s"' % filepath,
|
||||
],
|
||||
|
||||
name: 'go build %s/%s' % [GOOS, GOARCH],
|
||||
image: 'golang:1.23',
|
||||
environment: {
|
||||
GOOS: GOOS,
|
||||
GOARCH: GOARCH,
|
||||
GOPROXY: 'https://goproxy.io,direct',
|
||||
},
|
||||
commands: [
|
||||
'DIST_DIR=$(mktemp -d)',
|
||||
'go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags --always)" -o $DIST_DIR ./cmd/um',
|
||||
'mkdir -p dist',
|
||||
] + archive,
|
||||
};
|
||||
|
||||
local StepUploadArtifact(GOOS, GOARCH) = {
|
||||
local windows = GOOS == 'windows',
|
||||
local archiveExt = if windows then 'zip' else 'tar.gz',
|
||||
local filename = 'um-%s-%s-%s.%s' % [GOOS, GOARCH, '$(git describe --tags --always)', archiveExt],
|
||||
local filepath = 'dist/%s' % filename,
|
||||
local pkgname = '${DRONE_REPO_NAME}-build',
|
||||
|
||||
name: 'upload artifact',
|
||||
image: 'golang:1.23', // reuse golang:1.19 for curl
|
||||
environment: {
|
||||
DRONE_GITEA_SERVER: 'https://git.unlock-music.dev',
|
||||
GITEA_API_KEY: { from_secret: 'GITEA_API_KEY' },
|
||||
},
|
||||
commands: [
|
||||
'curl --fail --include --user "um-release-bot:$GITEA_API_KEY" ' +
|
||||
'--upload-file "%s" ' % filepath +
|
||||
'"$DRONE_GITEA_SERVER/api/packages/${DRONE_REPO_NAMESPACE}/generic/%s/${DRONE_BUILD_NUMBER}/%s"' % [pkgname, filename],
|
||||
'sha256sum %s' % filepath,
|
||||
'echo $DRONE_GITEA_SERVER/${DRONE_REPO_NAMESPACE}/-/packages/generic/%s/${DRONE_BUILD_NUMBER}' % pkgname,
|
||||
],
|
||||
};
|
||||
|
||||
|
||||
local PipelineBuild(GOOS, GOARCH, RUN_TEST) = {
|
||||
name: 'build %s/%s' % [GOOS, GOARCH],
|
||||
kind: 'pipeline',
|
||||
type: 'docker',
|
||||
steps: [
|
||||
{
|
||||
name: 'fetch tags',
|
||||
image: 'alpine/git',
|
||||
commands: ['git fetch --tags'],
|
||||
},
|
||||
] +
|
||||
(
|
||||
if RUN_TEST then [{
|
||||
name: 'go test',
|
||||
image: 'golang:1.23',
|
||||
environment: {
|
||||
GOPROXY: 'https://goproxy.io,direct',
|
||||
},
|
||||
commands: ['go test -v ./...'],
|
||||
}] else []
|
||||
)
|
||||
+
|
||||
[
|
||||
StepGoBuild(GOOS, GOARCH),
|
||||
StepUploadArtifact(GOOS, GOARCH),
|
||||
],
|
||||
trigger: {
|
||||
event: ['push', 'pull_request'],
|
||||
},
|
||||
};
|
||||
|
||||
local PipelineRelease() = {
|
||||
name: 'release',
|
||||
kind: 'pipeline',
|
||||
type: 'docker',
|
||||
steps: [
|
||||
{
|
||||
name: 'fetch tags',
|
||||
image: 'alpine/git',
|
||||
commands: ['git fetch --tags'],
|
||||
},
|
||||
{
|
||||
name: 'go test',
|
||||
image: 'golang:1.23',
|
||||
environment: {
|
||||
GOPROXY: 'https://goproxy.io,direct',
|
||||
},
|
||||
commands: ['go test -v ./...'],
|
||||
},
|
||||
StepGoBuild('linux', 'amd64'),
|
||||
StepGoBuild('linux', 'arm64'),
|
||||
StepGoBuild('linux', '386'),
|
||||
StepGoBuild('windows', 'amd64'),
|
||||
StepGoBuild('windows', 'arm64'),
|
||||
StepGoBuild('windows', '386'),
|
||||
StepGoBuild('darwin', 'amd64'),
|
||||
StepGoBuild('darwin', 'arm64'),
|
||||
{
|
||||
name: 'prepare root',
|
||||
image: 'golang:1.23',
|
||||
commands: [
|
||||
'mv dist/*.tar.gz dist/*.zip ./',
|
||||
],
|
||||
},
|
||||
CreateRelease(),
|
||||
],
|
||||
trigger: {
|
||||
event: ['tag'],
|
||||
},
|
||||
};
|
||||
|
||||
[
|
||||
PipelineBuild('linux', 'amd64', true),
|
||||
PipelineBuild('windows', 'amd64', false),
|
||||
PipelineBuild('darwin', 'amd64', false),
|
||||
PipelineRelease(),
|
||||
]
|
257
.drone.yml
257
.drone.yml
@ -1,257 +0,0 @@
|
||||
---
|
||||
kind: pipeline
|
||||
name: build linux/amd64
|
||||
steps:
|
||||
- commands:
|
||||
- git fetch --tags
|
||||
image: alpine/git
|
||||
name: fetch tags
|
||||
- commands:
|
||||
- go test -v ./...
|
||||
environment:
|
||||
GOPROXY: https://goproxy.io,direct
|
||||
image: golang:1.23
|
||||
name: go test
|
||||
- commands:
|
||||
- DIST_DIR=$(mktemp -d)
|
||||
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
|
||||
--always)" -o $DIST_DIR ./cmd/um
|
||||
- mkdir -p dist
|
||||
- tar -c -C $DIST_DIR um | gzip -9 > "dist/um-linux-amd64-$(git describe --tags
|
||||
--always).tar.gz"
|
||||
environment:
|
||||
GOARCH: amd64
|
||||
GOOS: linux
|
||||
GOPROXY: https://goproxy.io,direct
|
||||
image: golang:1.23
|
||||
name: go build linux/amd64
|
||||
- commands:
|
||||
- curl --fail --include --user "um-release-bot:$GITEA_API_KEY" --upload-file "dist/um-linux-amd64-$(git
|
||||
describe --tags --always).tar.gz" "$DRONE_GITEA_SERVER/api/packages/${DRONE_REPO_NAMESPACE}/generic/${DRONE_REPO_NAME}-build/${DRONE_BUILD_NUMBER}/um-linux-amd64-$(git
|
||||
describe --tags --always).tar.gz"
|
||||
- sha256sum dist/um-linux-amd64-$(git describe --tags --always).tar.gz
|
||||
- echo $DRONE_GITEA_SERVER/${DRONE_REPO_NAMESPACE}/-/packages/generic/${DRONE_REPO_NAME}-build/${DRONE_BUILD_NUMBER}
|
||||
environment:
|
||||
DRONE_GITEA_SERVER: https://git.unlock-music.dev
|
||||
GITEA_API_KEY:
|
||||
from_secret: GITEA_API_KEY
|
||||
image: golang:1.23
|
||||
name: upload artifact
|
||||
trigger:
|
||||
event:
|
||||
- push
|
||||
- pull_request
|
||||
type: docker
|
||||
---
|
||||
kind: pipeline
|
||||
name: build windows/amd64
|
||||
steps:
|
||||
- commands:
|
||||
- git fetch --tags
|
||||
image: alpine/git
|
||||
name: fetch tags
|
||||
- commands:
|
||||
- DIST_DIR=$(mktemp -d)
|
||||
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
|
||||
--always)" -o $DIST_DIR ./cmd/um
|
||||
- mkdir -p dist
|
||||
- command -v zip >/dev/null || (apt update && apt install -y zip)
|
||||
- zip -9 -j -r "dist/um-windows-amd64-$(git describe --tags --always).zip" $DIST_DIR
|
||||
environment:
|
||||
GOARCH: amd64
|
||||
GOOS: windows
|
||||
GOPROXY: https://goproxy.io,direct
|
||||
image: golang:1.23
|
||||
name: go build windows/amd64
|
||||
- commands:
|
||||
- curl --fail --include --user "um-release-bot:$GITEA_API_KEY" --upload-file "dist/um-windows-amd64-$(git
|
||||
describe --tags --always).zip" "$DRONE_GITEA_SERVER/api/packages/${DRONE_REPO_NAMESPACE}/generic/${DRONE_REPO_NAME}-build/${DRONE_BUILD_NUMBER}/um-windows-amd64-$(git
|
||||
describe --tags --always).zip"
|
||||
- sha256sum dist/um-windows-amd64-$(git describe --tags --always).zip
|
||||
- echo $DRONE_GITEA_SERVER/${DRONE_REPO_NAMESPACE}/-/packages/generic/${DRONE_REPO_NAME}-build/${DRONE_BUILD_NUMBER}
|
||||
environment:
|
||||
DRONE_GITEA_SERVER: https://git.unlock-music.dev
|
||||
GITEA_API_KEY:
|
||||
from_secret: GITEA_API_KEY
|
||||
image: golang:1.23
|
||||
name: upload artifact
|
||||
trigger:
|
||||
event:
|
||||
- push
|
||||
- pull_request
|
||||
type: docker
|
||||
---
|
||||
kind: pipeline
|
||||
name: build darwin/amd64
|
||||
steps:
|
||||
- commands:
|
||||
- git fetch --tags
|
||||
image: alpine/git
|
||||
name: fetch tags
|
||||
- commands:
|
||||
- DIST_DIR=$(mktemp -d)
|
||||
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
|
||||
--always)" -o $DIST_DIR ./cmd/um
|
||||
- mkdir -p dist
|
||||
- tar -c -C $DIST_DIR um | gzip -9 > "dist/um-darwin-amd64-$(git describe --tags
|
||||
--always).tar.gz"
|
||||
environment:
|
||||
GOARCH: amd64
|
||||
GOOS: darwin
|
||||
GOPROXY: https://goproxy.io,direct
|
||||
image: golang:1.23
|
||||
name: go build darwin/amd64
|
||||
- commands:
|
||||
- curl --fail --include --user "um-release-bot:$GITEA_API_KEY" --upload-file "dist/um-darwin-amd64-$(git
|
||||
describe --tags --always).tar.gz" "$DRONE_GITEA_SERVER/api/packages/${DRONE_REPO_NAMESPACE}/generic/${DRONE_REPO_NAME}-build/${DRONE_BUILD_NUMBER}/um-darwin-amd64-$(git
|
||||
describe --tags --always).tar.gz"
|
||||
- sha256sum dist/um-darwin-amd64-$(git describe --tags --always).tar.gz
|
||||
- echo $DRONE_GITEA_SERVER/${DRONE_REPO_NAMESPACE}/-/packages/generic/${DRONE_REPO_NAME}-build/${DRONE_BUILD_NUMBER}
|
||||
environment:
|
||||
DRONE_GITEA_SERVER: https://git.unlock-music.dev
|
||||
GITEA_API_KEY:
|
||||
from_secret: GITEA_API_KEY
|
||||
image: golang:1.23
|
||||
name: upload artifact
|
||||
trigger:
|
||||
event:
|
||||
- push
|
||||
- pull_request
|
||||
type: docker
|
||||
---
|
||||
kind: pipeline
|
||||
name: release
|
||||
steps:
|
||||
- commands:
|
||||
- git fetch --tags
|
||||
image: alpine/git
|
||||
name: fetch tags
|
||||
- commands:
|
||||
- go test -v ./...
|
||||
environment:
|
||||
GOPROXY: https://goproxy.io,direct
|
||||
image: golang:1.23
|
||||
name: go test
|
||||
- commands:
|
||||
- DIST_DIR=$(mktemp -d)
|
||||
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
|
||||
--always)" -o $DIST_DIR ./cmd/um
|
||||
- mkdir -p dist
|
||||
- tar -c -C $DIST_DIR um | gzip -9 > "dist/um-linux-amd64-$(git describe --tags
|
||||
--always).tar.gz"
|
||||
environment:
|
||||
GOARCH: amd64
|
||||
GOOS: linux
|
||||
GOPROXY: https://goproxy.io,direct
|
||||
image: golang:1.23
|
||||
name: go build linux/amd64
|
||||
- commands:
|
||||
- DIST_DIR=$(mktemp -d)
|
||||
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
|
||||
--always)" -o $DIST_DIR ./cmd/um
|
||||
- mkdir -p dist
|
||||
- tar -c -C $DIST_DIR um | gzip -9 > "dist/um-linux-arm64-$(git describe --tags
|
||||
--always).tar.gz"
|
||||
environment:
|
||||
GOARCH: arm64
|
||||
GOOS: linux
|
||||
GOPROXY: https://goproxy.io,direct
|
||||
image: golang:1.23
|
||||
name: go build linux/arm64
|
||||
- commands:
|
||||
- DIST_DIR=$(mktemp -d)
|
||||
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
|
||||
--always)" -o $DIST_DIR ./cmd/um
|
||||
- mkdir -p dist
|
||||
- tar -c -C $DIST_DIR um | gzip -9 > "dist/um-linux-386-$(git describe --tags --always).tar.gz"
|
||||
environment:
|
||||
GOARCH: "386"
|
||||
GOOS: linux
|
||||
GOPROXY: https://goproxy.io,direct
|
||||
image: golang:1.23
|
||||
name: go build linux/386
|
||||
- commands:
|
||||
- DIST_DIR=$(mktemp -d)
|
||||
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
|
||||
--always)" -o $DIST_DIR ./cmd/um
|
||||
- mkdir -p dist
|
||||
- command -v zip >/dev/null || (apt update && apt install -y zip)
|
||||
- zip -9 -j -r "dist/um-windows-amd64-$(git describe --tags --always).zip" $DIST_DIR
|
||||
environment:
|
||||
GOARCH: amd64
|
||||
GOOS: windows
|
||||
GOPROXY: https://goproxy.io,direct
|
||||
image: golang:1.23
|
||||
name: go build windows/amd64
|
||||
- commands:
|
||||
- DIST_DIR=$(mktemp -d)
|
||||
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
|
||||
--always)" -o $DIST_DIR ./cmd/um
|
||||
- mkdir -p dist
|
||||
- command -v zip >/dev/null || (apt update && apt install -y zip)
|
||||
- zip -9 -j -r "dist/um-windows-arm64-$(git describe --tags --always).zip" $DIST_DIR
|
||||
environment:
|
||||
GOARCH: arm64
|
||||
GOOS: windows
|
||||
GOPROXY: https://goproxy.io,direct
|
||||
image: golang:1.23
|
||||
name: go build windows/arm64
|
||||
- commands:
|
||||
- DIST_DIR=$(mktemp -d)
|
||||
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
|
||||
--always)" -o $DIST_DIR ./cmd/um
|
||||
- mkdir -p dist
|
||||
- command -v zip >/dev/null || (apt update && apt install -y zip)
|
||||
- zip -9 -j -r "dist/um-windows-386-$(git describe --tags --always).zip" $DIST_DIR
|
||||
environment:
|
||||
GOARCH: "386"
|
||||
GOOS: windows
|
||||
GOPROXY: https://goproxy.io,direct
|
||||
image: golang:1.23
|
||||
name: go build windows/386
|
||||
- commands:
|
||||
- DIST_DIR=$(mktemp -d)
|
||||
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
|
||||
--always)" -o $DIST_DIR ./cmd/um
|
||||
- mkdir -p dist
|
||||
- tar -c -C $DIST_DIR um | gzip -9 > "dist/um-darwin-amd64-$(git describe --tags
|
||||
--always).tar.gz"
|
||||
environment:
|
||||
GOARCH: amd64
|
||||
GOOS: darwin
|
||||
GOPROXY: https://goproxy.io,direct
|
||||
image: golang:1.23
|
||||
name: go build darwin/amd64
|
||||
- commands:
|
||||
- DIST_DIR=$(mktemp -d)
|
||||
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags
|
||||
--always)" -o $DIST_DIR ./cmd/um
|
||||
- mkdir -p dist
|
||||
- tar -c -C $DIST_DIR um | gzip -9 > "dist/um-darwin-arm64-$(git describe --tags
|
||||
--always).tar.gz"
|
||||
environment:
|
||||
GOARCH: arm64
|
||||
GOOS: darwin
|
||||
GOPROXY: https://goproxy.io,direct
|
||||
image: golang:1.23
|
||||
name: go build darwin/arm64
|
||||
- commands:
|
||||
- mv dist/*.tar.gz dist/*.zip ./
|
||||
image: golang:1.23
|
||||
name: prepare root
|
||||
- image: plugins/gitea-release
|
||||
name: create release
|
||||
settings:
|
||||
api_key:
|
||||
from_secret: GITEA_API_KEY
|
||||
base_url: https://git.unlock-music.dev
|
||||
checksum: sha256
|
||||
draft: true
|
||||
files:
|
||||
- um-*.tar.gz
|
||||
- um-*.zip
|
||||
title: ${DRONE_TAG}
|
||||
trigger:
|
||||
event:
|
||||
- tag
|
||||
type: docker
|
@ -73,6 +73,14 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
steps:
|
||||
- name: Checkout codebase
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Setup vars
|
||||
id: vars
|
||||
run: |
|
||||
echo "::set-output name=git_tag::$(git describe --tags --always)"
|
||||
- name: prepare archive
|
||||
run: |
|
||||
mkdir -p dist prepare
|
||||
@ -81,26 +89,8 @@ jobs:
|
||||
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: repack archive
|
||||
run: ./misc/repack.sh "${{ steps.vars.outputs.git_tag }}"
|
||||
- name: Publish all-in-one archive
|
||||
uses: christopherhx/gitea-upload-artifact@v4
|
||||
with:
|
||||
|
34
misc/repack.sh
Executable file
34
misc/repack.sh
Executable file
@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
# see .gitea/workflows/build.yml
|
||||
|
||||
APP_VERSION="${1:-$(git describe --tags --always)}"
|
||||
|
||||
for exe in prepare/*/um-*.exe; do
|
||||
name="$(basename "$exe" .exe)-$APP_VERSION"
|
||||
new_exe="$(dirname "$exe")/um.exe"
|
||||
mv "$exe" "$new_exe"
|
||||
|
||||
zip -9 -j "dist/${name}.zip" "$new_exe"
|
||||
rm -f "$new_exe"
|
||||
done
|
||||
|
||||
for exe in prepare/*/um-*; do
|
||||
name="$(basename "$exe")-$APP_VERSION"
|
||||
new_exe="$(dirname "$exe")/um"
|
||||
mv "$exe" "$new_exe"
|
||||
|
||||
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")" um |
|
||||
gzip -9 >"dist/${name}.tar.gz"
|
||||
rm -f "$exe"
|
||||
done
|
||||
|
||||
pushd dist
|
||||
sha256sum *.zip *.tar.gz >sha256sum.txt
|
||||
popd
|
Loading…
x
Reference in New Issue
Block a user