Build backend into docker image and push to GH registry #94
Workflow file for this run
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
| name: Build Go Binaries | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| pull_request: | |
| paths-ignore: | |
| - 'docs/**' | |
| - 'README.md' | |
| - 'zensical.toml' | |
| jobs: | |
| test: | |
| name: Run Go Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version-file: 'go.mod' | |
| cache: true | |
| - name: Run tests | |
| run: go test ./pkg/... | |
| build: | |
| name: Build ${{ matrix.goos }}-${{ matrix.goarch }} | |
| runs-on: ubuntu-latest | |
| needs: test | |
| strategy: | |
| matrix: | |
| include: | |
| - goos: linux | |
| goarch: amd64 | |
| - goos: linux | |
| goarch: arm64 | |
| - goos: darwin | |
| goarch: amd64 | |
| - goos: darwin | |
| goarch: arm64 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version-file: 'go.mod' | |
| cache: true | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| cache: 'yarn' | |
| - name: Get version | |
| id: version | |
| run: | | |
| if [[ "${{ github.event_name }}" == "release" ]]; then | |
| VERSION="${{ github.event.release.tag_name }}" | |
| # Use GitHub's pre-release flag | |
| IS_PRERELEASE="${{ github.event.release.prerelease }}" | |
| else | |
| VERSION="dev-$(git rev-parse --short HEAD)" | |
| IS_PRERELEASE="false" | |
| fi | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "is_prerelease=$IS_PRERELEASE" >> $GITHUB_OUTPUT | |
| echo "Building version: $VERSION (pre-release: $IS_PRERELEASE)" | |
| - name: Install dependencies | |
| run: yarn install --frozen-lockfile | |
| - name: Build binaries | |
| env: | |
| GOOS: ${{ matrix.goos }} | |
| GOARCH: ${{ matrix.goarch }} | |
| CGO_ENABLED: 0 | |
| GO_FLAGS: -trimpath -ldflags="-s -w" | |
| run: | | |
| echo "Building for $GOOS/$GOARCH..." | |
| make release | |
| echo "Build complete" | |
| ls -lh out/ | |
| - name: Create archive | |
| run: | | |
| ARCHIVE_NAME="hermes-${{ steps.version.outputs.version }}-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz" | |
| tar -czf "$ARCHIVE_NAME" -C out . | |
| echo "Created archive: $ARCHIVE_NAME" | |
| ls -lh "$ARCHIVE_NAME" | |
| tar -tvf "$ARCHIVE_NAME" | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: hermes-${{ steps.version.outputs.version }}-${{ matrix.goos }}-${{ matrix.goarch }} | |
| path: hermes-${{ steps.version.outputs.version }}-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz | |
| retention-days: 30 | |
| - name: Upload to release | |
| if: github.event_name == 'release' | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: hermes-${{ steps.version.outputs.version }}-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |