generated from deepin-community/template-repository-main
95 lines
2.8 KiB
YAML
95 lines
2.8 KiB
YAML
name: Build and Package Golang
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
pull_request:
|
|
branches:
|
|
- master
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y debhelper dh-golang build-essential wget
|
|
|
|
- name: Download Go Bootstrap
|
|
run: |
|
|
wget https://go.dev/dl/go1.22.6.linux-amd64.tar.gz
|
|
tar -C /usr/local -xzf go1.22.6.linux-amd64.tar.gz
|
|
mv /usr/local/go /usr/local/go-bootstrap
|
|
|
|
- name: Compile Golang from source
|
|
run: |
|
|
export GOROOT_BOOTSTRAP=/usr/local/go-bootstrap
|
|
cd src
|
|
./make.bash
|
|
cd ..
|
|
|
|
- name: Prepare .deb package structure
|
|
run: |
|
|
mkdir -p build/usr/local/go
|
|
find . -maxdepth 1 -mindepth 1 ! -name 'build' -exec cp -r {} build/usr/local/go/ \;
|
|
mkdir -p build/DEBIAN
|
|
cat <<EOF > build/DEBIAN/control
|
|
Package: golang
|
|
Version: 1.22.6-1
|
|
Section: devel
|
|
Priority: optional
|
|
Architecture: amd64
|
|
Maintainer: Deepin Community <community@deepin.org>
|
|
Depends: libc6 (>= 2.17)
|
|
Description: The Go programming language
|
|
Go is an open source programming language that makes it easy
|
|
to build simple, reliable, and efficient software.
|
|
EOF
|
|
|
|
- name: Build .deb package
|
|
run: |
|
|
dpkg-deb --build --root-owner-group --compression=gzip build golang_1.22.6-1_amd64.deb
|
|
|
|
- name: Verify .deb package
|
|
run: |
|
|
dpkg --info golang_1.22.6-1_amd64.deb
|
|
dpkg --contents golang_1.22.6-1_amd64.deb
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: golang-package
|
|
path: golang_1.22.6-1_amd64.deb
|
|
|
|
- name: Upload Debian Package to Gitea
|
|
run: |
|
|
PACKAGE_FILE="golang_1.22.6-1_amd64.deb"
|
|
OWNER="deepin-community"
|
|
GITEA_API_URL="http://192.168.9.154:3000/api/packages/${OWNER}/debian/pool/main/golang"
|
|
|
|
if [ ! -f "$PACKAGE_FILE" ]; then
|
|
echo "Error: Package file $PACKAGE_FILE not found."
|
|
exit 1
|
|
fi
|
|
|
|
echo "Uploading $PACKAGE_FILE to Gitea..."
|
|
|
|
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" -X PUT \
|
|
-H "Authorization: token ${{ secrets.GITEA2_TOKEN }}" \
|
|
-H "Content-Type: application/vnd.debian.binary-package" \
|
|
--data-binary @"$PACKAGE_FILE" \
|
|
"$GITEA_API_URL")
|
|
|
|
if [ "$RESPONSE" -eq 201 ]; then
|
|
echo "Package uploaded successfully!"
|
|
else
|
|
echo "Error: Failed to upload package. HTTP response code: $RESPONSE"
|
|
exit 1
|
|
fi
|