6e2ba16cbfdb0b99970639304b8b72d2332e29db
编译hello-world二进制文件:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o hello-world-linux-amd64 ./hello-world
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o hello-world-linux-arm64 ./hello-world
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o hello-world-darwin-amd64 ./hello-world
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o hello-world-darwin-arm64 ./hello-world
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o hello-world.exe ./hello-world
GOOS 可选值:
go tool dist list
🔐 Secrets 配置(在 Drone UI 中设置)
kind: secret name: registry_username data:
kind: secret name: registry_password data:
💡 使用 drone-cli 示例:
drone secret add \
--repository your-org/your-repo \
--name registry_username \
--data your-user
Git Submodule
项目基于 Git Submodule 挂载通用编译脚本时,可使用以下命令进行管理:
# 新创建项目增加 Submodule 配置
git submodule add https://git.colovu.com/docker/common.git .ci/common
# 删除 Submodule 配置
git submodule deinit .ci/common
git rm .ci/common
rm -rf .git/modules/.ci/common
rm -rf .ci/common
git commit -m "remove .ci/common"
git push
# 已检出项目,初始化 Submodule 配置(用于已检出项目,如 CI/CD 中)
git submodule update --init --recursive
# 新检出项目时,使用以下命令初始化 Submodule 配置(不适用于 CI/CD)
git clone --recursive-submodules https://git.colovu.com/docker/hello-world.git
# 更新 Submodule 对应的 Commit ID(使用新版本的 Submodule 项目提交内容)
git submodule update --remote
git commit -m "update .ci/common"
git push
# 切换使用的子模块分支
git submodule set-branch --branch main .ci/common
git submodule set-branch --branch stable .ci/common
Description
Languages
Dockerfile
52.1%
Go
47.9%