Skip to content

Commit

Permalink
build
Browse files Browse the repository at this point in the history
  • Loading branch information
le0pard committed Jul 6, 2024
1 parent 3a7c294 commit f1abbb0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 97 deletions.
101 changes: 15 additions & 86 deletions .github/workflows/build-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,100 +15,29 @@ jobs:
name: Build
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- name: Install linux build packages
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
sudo apt-get update -qq && sudo apt-get install -yq --no-install-recommends \
build-essential \
curl \
autoconf \
automake \
libtool \
pkg-config
- name: Install macos build packages
if: ${{ matrix.os == 'macos-latest' }}
run: |
brew install curl autoconf automake libtool pkg-config
- name: Install libpostal
run: |
mkdir /tmp/libpostal_code
mkdir /tmp/libpostal_datadir
- name: Install libpostal
run: git clone https://github.com/openvenues/libpostal
working-directory: /tmp/libpostal_code
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Install libpostal
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
./bootstrap.sh
./configure --datadir=/tmp/libpostal_datadir
make -j4
sudo make install
sudo ldconfig /usr/local/lib
working-directory: /tmp/libpostal_code/libpostal
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Install libpostal
if: ${{ matrix.os == 'macos-latest' }}
run: |
./bootstrap.sh
./configure --datadir=/tmp/libpostal_datadir --disable-sse2
make -j4
sudo make install
working-directory: /tmp/libpostal_code/libpostal

- name: CLI tests
run: |
go mod tidy
go test -v ./...
- name: Setup Syft for SBOM
uses: anchore/sbom-action/download-syft@v0
if: success() && startsWith(github.ref, 'refs/tags/')

# - name: Import GPG key
# id: import_gpg
# uses: crazy-max/ghaction-import-gpg@v6
# if: success() && startsWith(github.ref, 'refs/tags/')
# with:
# gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
# passphrase: ${{ secrets.GPG_PASSPHRASE }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
if: ${{ matrix.os == 'ubuntu-latest' }}
# if: success() && startsWith(github.ref, 'refs/tags/')
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
version: latest
args: release --clean --skip=publish --snapshot -f .goreleaser.linux.yml
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
# GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# - name: Run GoReleaser
# uses: goreleaser/goreleaser-action@v5
# if: ${{ matrix.os == 'macos-latest' }}
# # if: success() && startsWith(github.ref, 'refs/tags/')
# with:
# version: latest
# args: release --clean --skip=publish --snapshot -f .goreleaser.macos.yml
# # env:
# # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# # HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
# # GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
- name: Build and push
uses: docker/build-push-action@v6
with:
push: true
tags: user/app:latest
11 changes: 0 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,6 @@ COPY . ./
# Build the binary.
RUN go build -trimpath -ldflags="-s -w" -v -o postal_server

# Use the official Debian slim image for a lean production container.
# https://hub.docker.com/_/debian
# https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds
# FROM debian:bookworm-slim
# RUN set -x && apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
# ca-certificates && \
# rm -rf /var/lib/apt/lists/*

# Copy the binary to the production image from the builder stage.
# COPY --from=builder /app/postal_server /app/postal_server

EXPOSE 8000
# Run the web service on container startup.
CMD ["/app/postal_server"]

0 comments on commit f1abbb0

Please sign in to comment.