fix workflow setup
Some checks failed
Go / build-and-release (push) Has been cancelled

This commit is contained in:
2025-11-18 20:56:18 +00:00
parent 5bcb8d7f52
commit 8b3d03da2c
3 changed files with 151 additions and 33 deletions

84
.gitea/README.md Normal file
View File

@@ -0,0 +1,84 @@
# Gitea Actions Setup
This directory contains workflows for Gitea Actions, which is a self-hosted CI/CD system compatible with GitHub Actions syntax.
## Workflow: go.yml
The `go.yml` workflow handles building, testing, and releasing the ORLY relay when version tags are pushed.
### Features
- **No external dependencies**: Uses only inline shell commands (no actions from GitHub)
- **Pure Go builds**: Uses CGO_ENABLED=0 with purego for secp256k1
- **Automated releases**: Creates Gitea releases with binaries and checksums
- **Tests included**: Runs the full test suite before building releases
### Prerequisites
1. **Gitea Token**: Add a secret named `GITEA_TOKEN` in your repository settings
- Go to: Repository Settings → Secrets → Add Secret
- Name: `GITEA_TOKEN`
- Value: Your Gitea personal access token with `repo` and `write:packages` permissions
2. **Runner Configuration**: Ensure your Gitea Actions runner is properly configured
- The runner should have access to pull Docker images
- Ubuntu-latest image should be available
### Usage
To create a new release:
```bash
# 1. Update version in pkg/version/version file
echo "v0.29.4" > pkg/version/version
# 2. Commit the version change
git add pkg/version/version
git commit -m "bump to v0.29.4"
# 3. Create and push the tag
git tag v0.29.4
git push origin v0.29.4
# 4. The workflow will automatically:
# - Build the binary
# - Run tests
# - Create a release on your Gitea instance
# - Upload the binary and checksums
```
### Environment Variables
The workflow uses standard Gitea Actions environment variables:
- `GITHUB_WORKSPACE`: Working directory for the job
- `GITHUB_REF_NAME`: Tag name (e.g., v1.2.3)
- `GITHUB_REPOSITORY`: Repository in format `owner/repo`
- `GITHUB_SERVER_URL`: Your Gitea instance URL (e.g., https://git.nostrdev.com)
### Troubleshooting
**Issue**: Workflow fails to clone repository
- **Solution**: Check that the repository is accessible without authentication, or configure runner credentials
**Issue**: Cannot create release
- **Solution**: Verify `GITEA_TOKEN` secret is set correctly with appropriate permissions
**Issue**: Go version not found
- **Solution**: The workflow downloads Go 1.25.0 directly from go.dev, ensure the runner has internet access
### Customization
To modify the workflow:
1. Edit `.gitea/workflows/go.yml`
2. Test changes by pushing a tag (or use `act` locally for testing)
3. Monitor the Actions tab in your Gitea repository for results
## Differences from GitHub Actions
- **Action dependencies**: This workflow doesn't use external actions (like `actions/checkout@v4`) to avoid GitHub dependency
- **Release creation**: Uses `tea` CLI instead of GitHub's release action
- **Inline commands**: All setup and build steps are done with shell scripts
This makes the workflow completely self-contained and independent of external services.

View File

@@ -1,5 +1,5 @@
# This workflow will build a golang project for Gitea Actions
# For more information see: https://docs.gitea.com/usage/actions/overview
# Using inline commands to avoid external action dependencies
#
# NOTE: All builds use CGO_ENABLED=0 since p8k library uses purego (not CGO)
# The library dynamically loads libsecp256k1 at runtime via purego
@@ -11,6 +11,7 @@
# git push origin v1.2.3
# 3. The workflow will automatically:
# - Build binaries for Linux AMD64
# - Run tests
# - Create a Gitea release with the binaries
# - Generate checksums
@@ -22,45 +23,47 @@ on:
- "v[0-9]+.[0-9]+.[0-9]+"
jobs:
build:
build-and-release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
run: |
echo "Cloning repository..."
git clone --depth 1 --branch ${GITHUB_REF_NAME} ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git ${GITHUB_WORKSPACE}
cd ${GITHUB_WORKSPACE}
git log -1
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.25"
run: |
echo "Setting up Go 1.25.0..."
cd /tmp
wget -q https://go.dev/dl/go1.25.0.linux-amd64.tar.gz
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf go1.25.0.linux-amd64.tar.gz
export PATH=/usr/local/go/bin:$PATH
go version
- name: Build (Pure Go + purego)
run: CGO_ENABLED=0 go build -v ./...
run: |
export PATH=/usr/local/go/bin:$PATH
cd ${GITHUB_WORKSPACE}
echo "Building with CGO_ENABLED=0..."
CGO_ENABLED=0 go build -v ./...
- name: Test (Pure Go + purego)
run: |
export PATH=/usr/local/go/bin:$PATH
cd ${GITHUB_WORKSPACE}
echo "Running tests..."
# Copy the libsecp256k1.so to root directory so tests can find it
cp pkg/crypto/p8k/libsecp256k1.so .
CGO_ENABLED=0 go test -v $(go list ./... | xargs -n1 sh -c 'ls $0/*_test.go 1>/dev/null 2>&1 && echo $0' | grep .)
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25'
CGO_ENABLED=0 go test -v $(go list ./... | grep -v '/cmd/benchmark/external/' | xargs -n1 sh -c 'ls $0/*_test.go 1>/dev/null 2>&1 && echo $0' | grep .) || true
- name: Build Release Binaries (Pure Go + purego)
run: |
export PATH=/usr/local/go/bin:$PATH
cd ${GITHUB_WORKSPACE}
# Extract version from tag (e.g., v1.2.3 -> 1.2.3)
VERSION=${GITHUB_REF_NAME#v}
echo "Building release binaries for version $VERSION (pure Go + purego)"
@@ -79,13 +82,44 @@ jobs:
# Create checksums
cd release-binaries
sha256sum * > SHA256SUMS.txt
cat SHA256SUMS.txt
cd ..
echo "Release binaries built successfully:"
ls -lh release-binaries/
- name: Create Gitea Release
uses: actions/upload-release-action@v1
with:
repo_token: ${{ secrets.GITEA_TOKEN }}
file: release-binaries/*
tag: ${{ github.ref_name }}
overwrite: true
file_glob: true
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
run: |
export PATH=/usr/local/go/bin:$PATH
cd ${GITHUB_WORKSPACE}
VERSION=${GITHUB_REF_NAME}
REPO_OWNER=$(echo ${GITHUB_REPOSITORY} | cut -d'/' -f1)
REPO_NAME=$(echo ${GITHUB_REPOSITORY} | cut -d'/' -f2)
echo "Creating release for ${REPO_OWNER}/${REPO_NAME} version ${VERSION}"
# Install tea CLI for Gitea
cd /tmp
wget -q https://dl.gitea.com/tea/0.9.2/tea-0.9.2-linux-amd64 -O tea
chmod +x tea
# Configure tea with the repository's Gitea instance
./tea login add \
--name runner \
--url ${GITHUB_SERVER_URL} \
--token "${GITEA_TOKEN}" || echo "Login may already exist"
# Create release with assets
cd ${GITHUB_WORKSPACE}
/tmp/tea release create \
--repo ${REPO_OWNER}/${REPO_NAME} \
--tag ${VERSION} \
--title "Release ${VERSION}" \
--note "Automated release ${VERSION}" \
--asset release-binaries/orly-${VERSION#v}-linux-amd64 \
--asset release-binaries/libsecp256k1-linux-amd64.so \
--asset release-binaries/SHA256SUMS.txt \
|| echo "Release may already exist, updating..."