Skip to content

RpmBuild fails for GO binary application #27

@lordofscripts

Description

@lordofscripts

I have a GO application which I am trying to package as RPM with your workflow. Although I am on a Debian system, I installed the rpmbuild Debian package. I am able to build my RPM package locally. But it fails on the GitHub workflow.

The error is this:

RPM build errors:
Error: action failed with error: Error: The process '/usr/bin/rpmbuild' failed with exit code 1
/usr/bin/ls /github/home/rpmbuild/RPMS
/usr/bin/mkdir -p rpmbuild/SRPMS
stdout: 
stderr: 
/usr/bin/mkdir -p rpmbuild/RPMS
/usr/bin/cp /github/home/rpmbuild/SRPMS/ rpmbuild/SRPMS
cp: -r not specified; omitting directory '/github/home/rpmbuild/SRPMS/'
Error: The process '/usr/bin/cp' failed with exit code 1

My .spec file does NOT contain any cp command though, so this is coming from elsewhere. My GO application contains no errors.

My workflow looks as show below. Notice that I commented out the Release steps because my rpmbuild workflow runs AFTER my Release workflow has been successful:

# DEB & RPM Build & Packaging of GO project v1.0
name: Debian and RPM Packaging

on:
  workflow_run:
    workflows: [Multi platform Release]
    types:
      - completed

env:
  DIST: clys
  ARCH: x86_64
  PKG_NAME: caesarx

jobs:
  success:
    runs-on: ubuntu-latest
    if: ${{ github.event.workflow_run.conclusion == 'success' }}
    steps:
      - run: echo 'The Release workflow completed successfully.'
  failure:
    runs-on: ubuntu-latest
    if: ${{ github.event.workflow_run.conclusion == 'failure' }}
    steps:
      - run: echo 'The Release workflow failed.'
  exit:
    needs: failure
    runs-on: ubuntu-latest
    steps:
      - run: exit 1
  build_tarball:
    name: Build source archive
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Replace version in RPM spec so correct source is downloaded when building RPM
        run: sed -Ei 's/(^Version:[[:space:]]*).*/\1${{github.ref_name}}/' distrib/Fedora/${{ env.PKG_NAME }}.spec

      - name: Set up Go
        uses: actions/setup-go@v5
        with:
          go-version: '1.25'

      - name: Install dependencies
        run: |
          go get .

      - name: Build
        run: go build -v ./...        

      - name: Debug Info
        run: |
          echo "Current directory: $(pwd)"
          echo "Environment variables: $(printenv)"
          ls ./bin
          go version

# - name: Create source archive
#   run: tar -cvf ${{ env.PKG_NAME }}-${{ github.ref_name }}.tar.gz *

# - name: Upload source archive as artifact
#   uses: actions/upload-artifact@v4
#   with:
#     name: ${{ env.PKG_NAME }}-${{ github.ref_name }}.tar.gz
#     path: ${{ env.PKG_NAME }}-${{ github.ref_name }}.tar.gz

  build_rpm:
    name: Build .rpm package
    needs: build_tarball
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Replace version in RPM spec so correct source is downloaded when building RPM
        run: sed -Ei 's/(^Version:[[:space:]]*).*/\1${{github.ref_name}}/' distrib/Fedora/${{ env.PKG_NAME }}.spec

      - name: Run rpmbuild on RPM spec to produce package
        id: rpm
        uses: naveenrajm7/rpmbuild@master
        with:
          spec_file: distrib/Fedora/${{ env.PKG_NAME }}.spec

      - name: Upload .rpm package as artifact
        uses: actions/upload-artifact@v4
        with:
          name: ${{ env.PKG_NAME }}-${{ github.ref_name }}-1.${{ env.DIST }}.${{ env.ARCH }}.rpm
          path: rpmbuild/RPMS/${{ env.ARCH }}/*.rpm

  build_deb:
    name: Build .deb package
    needs: build_rpm
    runs-on: ubuntu-latest
    steps:
      - name: Download .rpm artifact
        uses: actions/download-artifact@v4
        id: download
        with:
          name: ${{ env.PKG_NAME }}-${{ github.ref_name }}-1.${{ env.DIST }}.${{ env.ARCH }}.rpm

      - name: find .
        run: find .

      - name: Convert .rpm to .deb
        run: |
          sudo apt install -y alien
          sudo alien -k --verbose --to-deb *.rpm

      - name: find .
        run: find . -exec readlink -f {} \;

      - name: Upload .deb package as artifact
        uses: actions/upload-artifact@v4
        with:
          name: ${{ env.PKG_NAME }}-${{ github.ref_name }}-1.${{ env.DIST }}.${{ env.ARCH }}.deb
          path: ${{ env.PKG_NAME }}*.deb

# release:
#   name: Create release with all assets
#   needs: [build_tarball, build_rpm, build_deb]
#   runs-on: ubuntu-latest
#   steps:
#     - name: Download .rpm artifact
#       uses: actions/download-artifact@v4

#     - name: find .
#       run: find .

#     - name: Release
#       uses: softprops/action-gh-release@v1
#       with:
#         files: |
#           ${{ env.PKG_NAME }}-${{ github.ref_name }}.tar.gz/*.tar.gz
#           ${{ env.PKG_NAME }}-${{ github.ref_name }}-1.${{ env.DIST }}.${{ env.ARCH }}.rpm/**/*.rpm
#           ${{ env.PKG_NAME }}-${{ github.ref_name }}-1.${{ env.DIST }}.${{ env.ARCH }}.deb/**/*.deb

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions