initial commit
This commit is contained in:
95
.gitea/workflows/build-go.yaml
Normal file
95
.gitea/workflows/build-go.yaml
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
name: Build Go Tarball
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get update -y
|
||||||
|
sudo apt-get install -y curl tar jq
|
||||||
|
|
||||||
|
- name: Determine latest Go release
|
||||||
|
id: get_go
|
||||||
|
run: |
|
||||||
|
LATEST=$(curl -s https://go.dev/dl/?mode=json | jq -r '.[0].version')
|
||||||
|
LATEST_NUM=${LATEST#go} # strip leading "go"
|
||||||
|
echo "LATEST=$LATEST_NUM" >> $GITHUB_ENV
|
||||||
|
echo "Latest Go version: $LATEST_NUM"
|
||||||
|
|
||||||
|
# - name: Check if package already exists
|
||||||
|
# env:
|
||||||
|
# GITEA_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
|
||||||
|
# LATEST: ${{ env.LATEST }}
|
||||||
|
# run: |
|
||||||
|
# EXISTS=$(curl -s -H "Authorization: token $GITEA_TOKEN" \
|
||||||
|
# "https://gitea.lulz.ltd/api/packages/list?owner=stacksmith&repo=go" || echo "[]" \
|
||||||
|
# | jq -r ".[] | select(.name==\"golang\" and .version==\"${LATEST}-debian12\") | .name")
|
||||||
|
# if [ -n "$EXISTS" ]; then
|
||||||
|
# echo "Package golang-${LATEST}-debian12 already exists. Skipping build."
|
||||||
|
# exit 0
|
||||||
|
# fi
|
||||||
|
|
||||||
|
- name: Download official Go tarball
|
||||||
|
env:
|
||||||
|
LATEST: ${{ env.LATEST }}
|
||||||
|
run: |
|
||||||
|
echo "Downloading: https://go.dev/dl/go${LATEST}.linux-amd64.tar.gz"
|
||||||
|
curl -LO https://go.dev/dl/go${LATEST}.linux-amd64.tar.gz
|
||||||
|
mkdir -p golang-${LATEST}-linux-amd64-debian-12/files
|
||||||
|
tar -xzf go${LATEST}.linux-amd64.tar.gz -C golang-${LATEST}-linux-amd64-debian-12/files
|
||||||
|
# ls -R golang-${LATEST}-linux-amd64-debian-12/files
|
||||||
|
|
||||||
|
- name: Package tarball
|
||||||
|
env:
|
||||||
|
LATEST: ${{ env.LATEST }}
|
||||||
|
run: |
|
||||||
|
tar -czf golang-${LATEST}-linux-amd64-debian-12.tar.gz golang-${LATEST}-linux-amd64-debian-12
|
||||||
|
ls -lh golang-${LATEST}-linux-amd64-debian-12.tar.gz
|
||||||
|
|
||||||
|
- name: Generate SHA256 checksum
|
||||||
|
run: |
|
||||||
|
sha256sum golang-${LATEST}-linux-amd64-debian-12.tar.gz > golang-${LATEST}-linux-amd64-debian-12.tar.gz.sha256
|
||||||
|
cat golang-${LATEST}-linux-amd64-debian-12.tar.gz.sha256
|
||||||
|
|
||||||
|
# - name: Upload to Gitea Packages
|
||||||
|
# env:
|
||||||
|
# GITEA_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
|
||||||
|
# LATEST: ${{ env.LATEST }}
|
||||||
|
# run: |
|
||||||
|
# curl -X POST \
|
||||||
|
# -H "Authorization: token $GITEA_TOKEN" \
|
||||||
|
# -F "package=@golang-${LATEST}-linux-amd64-debian-12.tar.gz" \
|
||||||
|
# "https://gitea.lulz.ltd/api/packages/upload?owner=stacksmith&repo=go&package_name=golang&package_version=${LATEST}-debian12"
|
||||||
|
# --upload-file "$TARFILE" \
|
||||||
|
# "https://gitea.lulz.ltd/api/packages/${OWNER}/generic/${REPOSITORY}/${VERSION}/$(basename $TARFILE)"
|
||||||
|
|
||||||
|
# - name: Install MinIO Client
|
||||||
|
# run: |
|
||||||
|
# wget https://dl.min.io/client/mc/release/linux-amd64/mc
|
||||||
|
# chmod +x mc
|
||||||
|
# sudo mv mc /usr/local/bin/
|
||||||
|
|
||||||
|
- name: Install MinIO Client
|
||||||
|
run: |
|
||||||
|
wget https://dl.min.io/client/mc/release/linux-amd64/mc
|
||||||
|
chmod +x mc
|
||||||
|
mv mc ./mc
|
||||||
|
|
||||||
|
- name: Configure MinIO
|
||||||
|
env:
|
||||||
|
MINIO_USER: ${{ secrets.CI_MINIO_USERNAME }}
|
||||||
|
MINIO_PASSWORD: ${{ secrets.CI_MINIO_PASSWORD }}
|
||||||
|
run: |
|
||||||
|
./mc alias set upload http://10.0.1.16 $MINIO_USER $MINIO_PASSWORD
|
||||||
|
|
||||||
|
- name: Upload to MinIO
|
||||||
|
run: |
|
||||||
|
./mc cp golang-${LATEST}-linux-amd64-debian-12.tar.gz upload/downloads/stacksmith/
|
||||||
|
./mc cp golang-${LATEST}-linux-amd64-debian-12.tar.gz.sha256 upload/downloads/stacksmith/
|
||||||
56
README.md
Normal file
56
README.md
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
# stacksmith/go
|
||||||
|
|
||||||
|
A repository and CI pipeline to automatically build and package Go binaries as lulz tarballs for Debian 12 (`bookworm`).
|
||||||
|
|
||||||
|
This project generates `golang-<version>-linux-amd64-debian-12.tar.gz` tarballs, suitable for inclusion in custom Docker images or CI/CD pipelines.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- Builds **latest Go releases** automatically from source.
|
||||||
|
- Produces a **lulz tarball** with `files/` folder structure.
|
||||||
|
- **Idempotent CI workflow**: skips building if the tarball already exists in Gitea Packages.
|
||||||
|
- Uploads tarballs to **Gitea Packages** for reuse in your pipelines.
|
||||||
|
- Works with **Debian 12 (Bookworm)** environments.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
### 1. Build locally
|
||||||
|
|
||||||
|
```
|
||||||
|
# Clone the repository
|
||||||
|
git clone https://gitea.lulz.ltd/stacksmith/go.git
|
||||||
|
cd go
|
||||||
|
|
||||||
|
# Determine the Go version to build
|
||||||
|
LATEST=v1.24.7 # or use the latest release
|
||||||
|
|
||||||
|
# Download and extract Go source
|
||||||
|
curl -LO https://go.dev/dl/${LATEST}.src.tar.gz
|
||||||
|
tar -xzf ${LATEST}.src.tar.gz
|
||||||
|
|
||||||
|
# Build Go
|
||||||
|
cd go/src
|
||||||
|
./make.bash
|
||||||
|
cd ../..
|
||||||
|
|
||||||
|
# Package tarball
|
||||||
|
mkdir -p golang-${LATEST}-linux-amd64-debian-12/files
|
||||||
|
cp -r go/* golang-${LATEST}-linux-amd64-debian-12/files/
|
||||||
|
tar -czf golang-${LATEST}-linux-amd64-debian-12.tar.gz golang-${LATEST}-linux-amd64-debian-12
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Use in Docker
|
||||||
|
|
||||||
|
```
|
||||||
|
FROM debian:bookworm-slim
|
||||||
|
|
||||||
|
COPY golang-1.24.7-linux-amd64-debian-12.tar.gz /opt/lulz/
|
||||||
|
RUN tar -zxf /opt/lulz/golang-1.24.7-linux-amd64-debian-12.tar.gz \
|
||||||
|
-C /opt/lulz --strip-components=2 --no-same-owner --wildcards '*/files'
|
||||||
|
|
||||||
|
ENV PATH="/opt/lulz/go/bin:${PATH}"
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user