Compare commits

...

2 Commits

Author SHA1 Message Date
ce9379d166 ci: produce zip for windows build
Some checks reported errors
continuous-integration/drone/push Build encountered an error
2024-10-21 05:46:52 +09:00
ec24497a1c docs: document steps to update CI pipeline 2024-10-21 05:46:27 +09:00
3 changed files with 251 additions and 232 deletions

View File

@ -17,21 +17,28 @@ local CreateRelease() = {
local StepGoBuild(GOOS, GOARCH) = { local StepGoBuild(GOOS, GOARCH) = {
local filepath = 'dist/um-%s-%s.tar.gz' % [GOOS, GOARCH], local archiveExt = if GOOS == 'windows' then 'zip' else 'tar.gz',
local filepath = 'dist/um-%s-%s.%s' % [GOOS, GOARCH, archiveExt],
// run zip or tar command depending on GOOS been windows or other
local archive = if GOOS == 'windows' then [
'zip -9 -j -r "%s" $DIST_DIR' % filepath,
] else [
'tar -zc -C $DIST_DIR um | gzip -9 > "%s"' % filepath,
],
name: 'go build %s/%s' % [GOOS, GOARCH], name: 'go build %s/%s' % [GOOS, GOARCH],
image: 'golang:1.22', image: 'golang:1.22',
environment: { environment: {
GOOS: GOOS, GOOS: GOOS,
GOARCH: GOARCH, GOARCH: GOARCH,
GOPROXY: "https://goproxy.io,direct", GOPROXY: 'https://goproxy.io,direct',
}, },
commands: [ commands: [
'DIST_DIR=$(mktemp -d)', 'DIST_DIR=$(mktemp -d)',
'go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags --always)" -o $DIST_DIR ./cmd/um', 'go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags --always)" -o $DIST_DIR ./cmd/um',
'mkdir -p dist', 'mkdir -p dist',
'tar cz -f %s -C $DIST_DIR .' % filepath, ] + archive,
],
}; };
local StepUploadArtifact(GOOS, GOARCH) = { local StepUploadArtifact(GOOS, GOARCH) = {
@ -71,7 +78,7 @@ local PipelineBuild(GOOS, GOARCH, RUN_TEST) = {
name: 'go test', name: 'go test',
image: 'golang:1.22', image: 'golang:1.22',
environment: { environment: {
GOPROXY: "https://goproxy.io,direct", GOPROXY: 'https://goproxy.io,direct',
}, },
commands: ['go test -v ./...'], commands: ['go test -v ./...'],
}] else [] }] else []
@ -100,7 +107,7 @@ local PipelineRelease() = {
name: 'go test', name: 'go test',
image: 'golang:1.22', image: 'golang:1.22',
environment: { environment: {
GOPROXY: "https://goproxy.io,direct", GOPROXY: 'https://goproxy.io,direct',
}, },
commands: ['go test -v ./...'], commands: ['go test -v ./...'],
}, },

View File

@ -1,226 +1,222 @@
--- - kind: pipeline
kind: pipeline name: build linux/amd64
name: build linux/amd64 steps:
steps: - commands:
- commands: - git fetch --tags
- git fetch --tags image: alpine/git
image: alpine/git name: fetch tags
name: fetch tags - commands:
- commands: - go test -v ./...
- go test -v ./... environment:
environment: GOPROXY: https://goproxy.io,direct
GOPROXY: https://goproxy.io,direct image: golang:1.22
image: golang:1.22 name: go test
name: go test - commands:
- commands: - DIST_DIR=$(mktemp -d)
- DIST_DIR=$(mktemp -d) - go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags --tags --always)" -o $DIST_DIR ./cmd/um
--always)" -o $DIST_DIR ./cmd/um - mkdir -p dist
- mkdir -p dist - tar -zc -C $DIST_DIR um | gzip -9 > "dist/um-linux-amd64.tar.gz"
- tar cz -f dist/um-linux-amd64.tar.gz -C $DIST_DIR . environment:
environment: GOARCH: amd64
GOARCH: amd64 GOOS: linux
GOOS: linux GOPROXY: https://goproxy.io,direct
GOPROXY: https://goproxy.io,direct image: golang:1.22
image: golang:1.22 name: go build linux/amd64
name: go build linux/amd64 - commands:
- commands: - curl --fail --include --user "um-release-bot:$GITEA_API_KEY" --upload-file
- curl --fail --include --user "um-release-bot:$GITEA_API_KEY" --upload-file "dist/um-linux-amd64.tar.gz" "dist/um-linux-amd64.tar.gz" "$DRONE_GITEA_SERVER/api/packages/${DRONE_REPO_NAMESPACE}/generic/${DRONE_REPO_NAME}-build/${DRONE_BUILD_NUMBER}/um-linux-amd64.tar.gz"
"$DRONE_GITEA_SERVER/api/packages/${DRONE_REPO_NAMESPACE}/generic/${DRONE_REPO_NAME}-build/${DRONE_BUILD_NUMBER}/um-linux-amd64.tar.gz" - sha256sum dist/um-linux-amd64.tar.gz
- sha256sum dist/um-linux-amd64.tar.gz - echo $DRONE_GITEA_SERVER/${DRONE_REPO_NAMESPACE}/-/packages/generic/${DRONE_REPO_NAME}-build/${DRONE_BUILD_NUMBER}
- echo $DRONE_GITEA_SERVER/${DRONE_REPO_NAMESPACE}/-/packages/generic/${DRONE_REPO_NAME}-build/${DRONE_BUILD_NUMBER} environment:
environment: DRONE_GITEA_SERVER: https://git.unlock-music.dev
DRONE_GITEA_SERVER: https://git.unlock-music.dev GITEA_API_KEY:
GITEA_API_KEY: from_secret: GITEA_API_KEY
from_secret: GITEA_API_KEY image: golang:1.22
image: golang:1.22 name: upload artifact
name: upload artifact trigger:
trigger: event:
event: - push
- push - pull_request
- pull_request type: docker
type: docker - kind: pipeline
--- name: build windows/amd64
kind: pipeline steps:
name: build windows/amd64 - commands:
steps: - git fetch --tags
- commands: image: alpine/git
- git fetch --tags name: fetch tags
image: alpine/git - commands:
name: fetch tags - DIST_DIR=$(mktemp -d)
- commands: - go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe
- DIST_DIR=$(mktemp -d) --tags --always)" -o $DIST_DIR ./cmd/um
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags - mkdir -p dist
--always)" -o $DIST_DIR ./cmd/um - zip -9 -j -r "dist/um-windows-amd64.zip" $DIST_DIR
- mkdir -p dist environment:
- tar cz -f dist/um-windows-amd64.tar.gz -C $DIST_DIR . GOARCH: amd64
environment: GOOS: windows
GOARCH: amd64 GOPROXY: https://goproxy.io,direct
GOOS: windows image: golang:1.22
GOPROXY: https://goproxy.io,direct name: go build windows/amd64
image: golang:1.22 - commands:
name: go build windows/amd64 - curl --fail --include --user "um-release-bot:$GITEA_API_KEY" --upload-file
- commands: "dist/um-windows-amd64.tar.gz" "$DRONE_GITEA_SERVER/api/packages/${DRONE_REPO_NAMESPACE}/generic/${DRONE_REPO_NAME}-build/${DRONE_BUILD_NUMBER}/um-windows-amd64.tar.gz"
- curl --fail --include --user "um-release-bot:$GITEA_API_KEY" --upload-file "dist/um-windows-amd64.tar.gz" - sha256sum dist/um-windows-amd64.tar.gz
"$DRONE_GITEA_SERVER/api/packages/${DRONE_REPO_NAMESPACE}/generic/${DRONE_REPO_NAME}-build/${DRONE_BUILD_NUMBER}/um-windows-amd64.tar.gz" - echo $DRONE_GITEA_SERVER/${DRONE_REPO_NAMESPACE}/-/packages/generic/${DRONE_REPO_NAME}-build/${DRONE_BUILD_NUMBER}
- sha256sum dist/um-windows-amd64.tar.gz environment:
- echo $DRONE_GITEA_SERVER/${DRONE_REPO_NAMESPACE}/-/packages/generic/${DRONE_REPO_NAME}-build/${DRONE_BUILD_NUMBER} DRONE_GITEA_SERVER: https://git.unlock-music.dev
environment: GITEA_API_KEY:
DRONE_GITEA_SERVER: https://git.unlock-music.dev from_secret: GITEA_API_KEY
GITEA_API_KEY: image: golang:1.22
from_secret: GITEA_API_KEY name: upload artifact
image: golang:1.22 trigger:
name: upload artifact event:
trigger: - push
event: - pull_request
- push type: docker
- pull_request - kind: pipeline
type: docker name: build darwin/amd64
--- steps:
kind: pipeline - commands:
name: build darwin/amd64 - git fetch --tags
steps: image: alpine/git
- commands: name: fetch tags
- git fetch --tags - commands:
image: alpine/git - DIST_DIR=$(mktemp -d)
name: fetch tags - go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe
- commands: --tags --always)" -o $DIST_DIR ./cmd/um
- DIST_DIR=$(mktemp -d) - mkdir -p dist
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags - tar -zc -C $DIST_DIR um | gzip -9 > "dist/um-darwin-amd64.tar.gz"
--always)" -o $DIST_DIR ./cmd/um environment:
- mkdir -p dist GOARCH: amd64
- tar cz -f dist/um-darwin-amd64.tar.gz -C $DIST_DIR . GOOS: darwin
environment: GOPROXY: https://goproxy.io,direct
GOARCH: amd64 image: golang:1.22
GOOS: darwin name: go build darwin/amd64
GOPROXY: https://goproxy.io,direct - commands:
image: golang:1.22 - curl --fail --include --user "um-release-bot:$GITEA_API_KEY" --upload-file
name: go build darwin/amd64 "dist/um-darwin-amd64.tar.gz" "$DRONE_GITEA_SERVER/api/packages/${DRONE_REPO_NAMESPACE}/generic/${DRONE_REPO_NAME}-build/${DRONE_BUILD_NUMBER}/um-darwin-amd64.tar.gz"
- commands: - sha256sum dist/um-darwin-amd64.tar.gz
- curl --fail --include --user "um-release-bot:$GITEA_API_KEY" --upload-file "dist/um-darwin-amd64.tar.gz" - echo $DRONE_GITEA_SERVER/${DRONE_REPO_NAMESPACE}/-/packages/generic/${DRONE_REPO_NAME}-build/${DRONE_BUILD_NUMBER}
"$DRONE_GITEA_SERVER/api/packages/${DRONE_REPO_NAMESPACE}/generic/${DRONE_REPO_NAME}-build/${DRONE_BUILD_NUMBER}/um-darwin-amd64.tar.gz" environment:
- sha256sum dist/um-darwin-amd64.tar.gz DRONE_GITEA_SERVER: https://git.unlock-music.dev
- echo $DRONE_GITEA_SERVER/${DRONE_REPO_NAMESPACE}/-/packages/generic/${DRONE_REPO_NAME}-build/${DRONE_BUILD_NUMBER} GITEA_API_KEY:
environment: from_secret: GITEA_API_KEY
DRONE_GITEA_SERVER: https://git.unlock-music.dev image: golang:1.22
GITEA_API_KEY: name: upload artifact
from_secret: GITEA_API_KEY trigger:
image: golang:1.22 event:
name: upload artifact - push
trigger: - pull_request
event: type: docker
- push - kind: pipeline
- pull_request name: release
type: docker steps:
--- - commands:
kind: pipeline - git fetch --tags
name: release image: alpine/git
steps: name: fetch tags
- commands: - commands:
- git fetch --tags - go test -v ./...
image: alpine/git environment:
name: fetch tags GOPROXY: https://goproxy.io,direct
- commands: image: golang:1.22
- go test -v ./... name: go test
environment: - commands:
GOPROXY: https://goproxy.io,direct - DIST_DIR=$(mktemp -d)
image: golang:1.22 - go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe
name: go test --tags --always)" -o $DIST_DIR ./cmd/um
- commands: - mkdir -p dist
- DIST_DIR=$(mktemp -d) - tar -zc -C $DIST_DIR um | gzip -9 > "dist/um-linux-amd64.tar.gz"
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags environment:
--always)" -o $DIST_DIR ./cmd/um GOARCH: amd64
- mkdir -p dist GOOS: linux
- tar cz -f dist/um-linux-amd64.tar.gz -C $DIST_DIR . GOPROXY: https://goproxy.io,direct
environment: image: golang:1.22
GOARCH: amd64 name: go build linux/amd64
GOOS: linux - commands:
GOPROXY: https://goproxy.io,direct - DIST_DIR=$(mktemp -d)
image: golang:1.22 - go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe
name: go build linux/amd64 --tags --always)" -o $DIST_DIR ./cmd/um
- commands: - mkdir -p dist
- DIST_DIR=$(mktemp -d) - tar -zc -C $DIST_DIR um | gzip -9 > "dist/um-linux-arm64.tar.gz"
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags environment:
--always)" -o $DIST_DIR ./cmd/um GOARCH: arm64
- mkdir -p dist GOOS: linux
- tar cz -f dist/um-linux-arm64.tar.gz -C $DIST_DIR . GOPROXY: https://goproxy.io,direct
environment: image: golang:1.22
GOARCH: arm64 name: go build linux/arm64
GOOS: linux - commands:
GOPROXY: https://goproxy.io,direct - DIST_DIR=$(mktemp -d)
image: golang:1.22 - go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe
name: go build linux/arm64 --tags --always)" -o $DIST_DIR ./cmd/um
- commands: - mkdir -p dist
- DIST_DIR=$(mktemp -d) - tar -zc -C $DIST_DIR um | gzip -9 > "dist/um-linux-386.tar.gz"
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags environment:
--always)" -o $DIST_DIR ./cmd/um GOARCH: '386'
- mkdir -p dist GOOS: linux
- tar cz -f dist/um-linux-386.tar.gz -C $DIST_DIR . GOPROXY: https://goproxy.io,direct
environment: image: golang:1.22
GOARCH: "386" name: go build linux/386
GOOS: linux - commands:
GOPROXY: https://goproxy.io,direct - DIST_DIR=$(mktemp -d)
image: golang:1.22 - go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe
name: go build linux/386 --tags --always)" -o $DIST_DIR ./cmd/um
- commands: - mkdir -p dist
- DIST_DIR=$(mktemp -d) - zip -9 -j -r "dist/um-windows-amd64.zip" $DIST_DIR
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags environment:
--always)" -o $DIST_DIR ./cmd/um GOARCH: amd64
- mkdir -p dist GOOS: windows
- tar cz -f dist/um-windows-amd64.tar.gz -C $DIST_DIR . GOPROXY: https://goproxy.io,direct
environment: image: golang:1.22
GOARCH: amd64 name: go build windows/amd64
GOOS: windows - commands:
GOPROXY: https://goproxy.io,direct - DIST_DIR=$(mktemp -d)
image: golang:1.22 - go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe
name: go build windows/amd64 --tags --always)" -o $DIST_DIR ./cmd/um
- commands: - mkdir -p dist
- DIST_DIR=$(mktemp -d) - zip -9 -j -r "dist/um-windows-386.zip" $DIST_DIR
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags environment:
--always)" -o $DIST_DIR ./cmd/um GOARCH: '386'
- mkdir -p dist GOOS: windows
- tar cz -f dist/um-windows-386.tar.gz -C $DIST_DIR . GOPROXY: https://goproxy.io,direct
environment: image: golang:1.22
GOARCH: "386" name: go build windows/386
GOOS: windows - commands:
GOPROXY: https://goproxy.io,direct - DIST_DIR=$(mktemp -d)
image: golang:1.22 - go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe
name: go build windows/386 --tags --always)" -o $DIST_DIR ./cmd/um
- commands: - mkdir -p dist
- DIST_DIR=$(mktemp -d) - tar -zc -C $DIST_DIR um | gzip -9 > "dist/um-darwin-amd64.tar.gz"
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags environment:
--always)" -o $DIST_DIR ./cmd/um GOARCH: amd64
- mkdir -p dist GOOS: darwin
- tar cz -f dist/um-darwin-amd64.tar.gz -C $DIST_DIR . GOPROXY: https://goproxy.io,direct
environment: image: golang:1.22
GOARCH: amd64 name: go build darwin/amd64
GOOS: darwin - commands:
GOPROXY: https://goproxy.io,direct - DIST_DIR=$(mktemp -d)
image: golang:1.22 - go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe
name: go build darwin/amd64 --tags --always)" -o $DIST_DIR ./cmd/um
- commands: - mkdir -p dist
- DIST_DIR=$(mktemp -d) - tar -zc -C $DIST_DIR um | gzip -9 > "dist/um-darwin-arm64.tar.gz"
- go build -v -trimpath -ldflags="-w -s -X main.AppVersion=$(git describe --tags environment:
--always)" -o $DIST_DIR ./cmd/um GOARCH: arm64
- mkdir -p dist GOOS: darwin
- tar cz -f dist/um-darwin-arm64.tar.gz -C $DIST_DIR . GOPROXY: https://goproxy.io,direct
environment: image: golang:1.22
GOARCH: arm64 name: go build darwin/arm64
GOOS: darwin - image: plugins/gitea-release
GOPROXY: https://goproxy.io,direct name: create release
image: golang:1.22 settings:
name: go build darwin/arm64 api_key:
- image: plugins/gitea-release from_secret: GITEA_API_KEY
name: create release base_url: https://git.unlock-music.dev
settings: checksum: sha256
api_key: draft: true
from_secret: GITEA_API_KEY files: dist/*
base_url: https://git.unlock-music.dev title: ${DRONE_TAG}
checksum: sha256 trigger:
draft: true event:
files: dist/* - tag
title: ${DRONE_TAG} type: docker
trigger:
event:
- tag
type: docker

View File

@ -25,3 +25,19 @@ Original: Web Edition https://git.unlock-music.dev/um/web
- Drag the encrypted file to `um.exe` (Tested on Windows) - Drag the encrypted file to `um.exe` (Tested on Windows)
- Run: `./um [-o <output dir>] [-i] <input dir/file>` - Run: `./um [-o <output dir>] [-i] <input dir/file>`
- Use `./um -h` to show help menu - Use `./um -h` to show help menu
## Update CI pipeline
Ensure `jsonnet` and `yq` is installed.
```sh
# Debian / Ubuntu etc:
sudo apt install jsonnet yq
```
1. Edit `.drone.jsonnet`
2. Update drone CI pipeline:
```sh
jsonnet .drone.jsonnet | yq -y > .drone.yml
```