-
Notifications
You must be signed in to change notification settings - Fork 8
feat: add reproducible debian packaging with goreleaser & CI workflow #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
MoeMahhouk
wants to merge
3
commits into
flashbots:main
Choose a base branch
from
MoeMahhouk:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,7 +64,7 @@ jobs: | |
run: go install mvdan.cc/[email protected] | ||
|
||
- name: Install staticcheck | ||
run: go install honnef.co/go/tools/cmd/staticcheck@2025.1.1 | ||
run: go install honnef.co/go/tools/cmd/staticcheck@v0.6.1 | ||
|
||
- name: Install golangci-lint | ||
run: go install github.com/golangci/golangci-lint/cmd/[email protected] | ||
|
@@ -80,3 +80,33 @@ jobs: | |
go mod tidy | ||
git update-index -q --really-refresh | ||
git diff-index HEAD | ||
|
||
reproducibility-test: | ||
name: Test Reproducible Builds | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.24' | ||
cache: true | ||
|
||
- name: Set SOURCE_DATE_EPOCH for reproducible builds | ||
run: echo "SOURCE_DATE_EPOCH=$(git log -1 --format=%ct)" >> $GITHUB_ENV | ||
|
||
- name: Test reproducible builds | ||
run: | | ||
# Install GoReleaser | ||
go install github.com/goreleaser/goreleaser/v2@latest | ||
|
||
# Run reproducibility test | ||
make package-test-reproducible | ||
|
||
echo "✅ Reproducibility test passed" | ||
env: | ||
SOURCE_DATE_EPOCH: ${{ env.SOURCE_DATE_EPOCH }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,9 +7,10 @@ on: | |
|
||
permissions: | ||
contents: write | ||
packages: write | ||
|
||
jobs: | ||
build_and_release: | ||
reproducibility-test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
|
@@ -20,97 +21,101 @@ jobs: | |
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: ^v1.24 | ||
go-version: '1.24' | ||
cache: true | ||
|
||
- name: Set SOURCE_DATE_EPOCH for reproducible builds | ||
run: echo "SOURCE_DATE_EPOCH=$(git log -1 --format=%ct)" >> $GITHUB_ENV | ||
|
||
- name: Test reproducible builds | ||
run: | | ||
# Install GoReleaser | ||
go install github.com/goreleaser/goreleaser/v2@latest | ||
|
||
# Run reproducibility test | ||
make package-test-reproducible | ||
|
||
echo "✅ Reproducibility test passed" | ||
env: | ||
SOURCE_DATE_EPOCH: ${{ env.SOURCE_DATE_EPOCH }} | ||
|
||
- name: Build | ||
run: make build | ||
release: | ||
runs-on: ubuntu-latest | ||
needs: reproducibility-test # Only run if reproducibility test passes | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.24' | ||
cache: true | ||
|
||
- name: Set SOURCE_DATE_EPOCH for reproducible builds | ||
run: echo "SOURCE_DATE_EPOCH=$(git log -1 --format=%ct)" >> $GITHUB_ENV | ||
|
||
- name: Set up packaging dependencies | ||
run: | | ||
# Install nfpm for packaging | ||
echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | sudo tee /etc/apt/sources.list.d/goreleaser.list | ||
sudo apt-get update | ||
sudo apt-get install -y nfpm | ||
|
||
- name: Import GPG key (if available) | ||
id: import_gpg | ||
uses: crazy-max/ghaction-import-gpg@v6 | ||
if: env.GPG_PRIVATE_KEY != '' | ||
with: | ||
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} | ||
passphrase: ${{ secrets.GPG_PASSPHRASE }} | ||
env: | ||
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} | ||
|
||
# https://goreleaser.com/cmd/goreleaser_release/ | ||
- name: Run GoReleaser | ||
- name: Run GoReleaser (Release) | ||
uses: goreleaser/goreleaser-action@v6 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
distribution: goreleaser | ||
version: "~> v2" | ||
args: release --config .goreleaser.yaml | ||
args: release --clean | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
SOURCE_DATE_EPOCH: ${{ env.SOURCE_DATE_EPOCH }} | ||
GPG_KEY_PATH: ${{ steps.import_gpg.outputs.keyid && format('/tmp/gpg-{0}.key', steps.import_gpg.outputs.keyid) || '' }} | ||
NFPM_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | ||
|
||
# docker-image: | ||
# name: Publish Docker Image | ||
# runs-on: ubuntu-latest | ||
|
||
# steps: | ||
# - name: Checkout sources | ||
# uses: actions/checkout@v2 | ||
|
||
# - name: Get tag version | ||
# run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | ||
|
||
# - name: Print version | ||
# run: | | ||
# echo $RELEASE_VERSION | ||
# echo ${{ env.RELEASE_VERSION }} | ||
|
||
# - name: Set up QEMU | ||
# uses: docker/setup-qemu-action@v3 | ||
|
||
# - name: Set up Docker Buildx | ||
# uses: docker/setup-buildx-action@v3 | ||
|
||
# - name: Extract metadata (tags, labels) for Docker | ||
# id: meta | ||
# uses: docker/metadata-action@v5 | ||
# with: | ||
# images: flashbots/go-template | ||
# tags: | | ||
# type=sha | ||
# type=pep440,pattern={{version}} | ||
# type=pep440,pattern={{major}}.{{minor}} | ||
# type=raw,value=latest,enable=${{ !contains(env.RELEASE_VERSION, '-') }} | ||
|
||
# - name: Login to DockerHub | ||
# uses: docker/login-action@v3 | ||
# with: | ||
# username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
# password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
# - name: Go Build Cache for Docker | ||
# uses: actions/cache@v3 | ||
# with: | ||
# path: go-build-cache | ||
# key: ${{ runner.os }}-go-build-cache-${{ hashFiles('**/go.sum') }} | ||
|
||
# - name: inject go-build-cache into docker | ||
# uses: reproducible-containers/[email protected] | ||
# with: | ||
# cache-source: go-build-cache | ||
|
||
# - name: Build and push | ||
# uses: docker/build-push-action@v5 | ||
# with: | ||
# context: . | ||
# build-args: | | ||
# VERSION=${{ env.RELEASE_VERSION }} | ||
# push: true | ||
# tags: ${{ steps.meta.outputs.tags }} | ||
# labels: ${{ steps.meta.outputs.labels }} | ||
# platforms: linux/amd64,linux/arm64 | ||
# cache-from: type=gha | ||
# cache-to: type=gha,mode=max | ||
|
||
# github-release: | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - name: Checkout sources | ||
# uses: actions/checkout@v2 | ||
|
||
# - name: Create release | ||
# id: create_release | ||
# uses: actions/create-release@v1 | ||
# env: | ||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token | ||
# with: | ||
# tag_name: ${{ github.ref }} | ||
# release_name: ${{ github.ref }} | ||
# draft: false | ||
# prerelease: false | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: packages | ||
path: | | ||
dist/*.deb | ||
dist/*.rpm | ||
dist/*.tar.gz | ||
dist/checksums.txt | ||
retention-days: 30 | ||
|
||
- name: Test package installation | ||
run: | | ||
# Test Debian package installation - use AMD64 package for GitHub Actions runner | ||
DEB_FILE=$(find dist -name "*httpserver*_linux_amd64.deb" | head -1) | ||
if [ -n "$DEB_FILE" ]; then | ||
echo "Testing package installation: $DEB_FILE" | ||
sudo dpkg -i "$DEB_FILE" || true | ||
sudo apt-get -f install -y | ||
|
||
# Test if binary is installed and working | ||
/usr/bin/go-template-httpserver --help | ||
|
||
# Test systemd service | ||
sudo systemctl daemon-reload | ||
sudo systemctl is-enabled go-template-httpserver | ||
|
||
echo "✅ Package installation test passed" | ||
else | ||
echo "❌ No AMD64 .deb file found for testing" | ||
exit 1 | ||
fi |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?