Skip to content
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

Add a Github workflow to do cross OS builds. #125

Open
gedw99 opened this issue Jan 17, 2024 · 0 comments
Open

Add a Github workflow to do cross OS builds. #125

gedw99 opened this issue Jan 17, 2024 · 0 comments

Comments

@gedw99
Copy link

gedw99 commented Jan 17, 2024

@paulsmith

#121 seems to fix Windows, so how about if we add a GitHub workflow to use a build matrix to build on Windows, Mac and Linux ?

This GitHub workflow calls make "ci-all", so all we need to do is to add a make target for it to the Makefile. Github workflows will then call it for each OS.

It can also build for many go versions by adding extra params...

name: make

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

on:
  # Runs on pushes targeting the default branch
  push:
    branches:
      - 'main'
    tags:
      - 'v*'
  # Runs on PRS targeting any branch
  pull_request:

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

env:
  DESTDIR: ./bin

jobs:

  #
  # Tests for all platforms. Runs a matrix build on Windows, Linux and Mac,
  # with the list of expected supported Go versions (current, previous).
  #

  build:
    name: Build and test
    strategy:
      fail-fast: false
      matrix:
        os: [ ubuntu-latest, macos-latest, windows-latest ]
        go-version: [ 1.21.5 ]
        target: [ "ci-all", ]
    runs-on: ${{ matrix.os }}
    steps:

      # Install go: https://github.com/actions/setup-go/releases/tag/v5.0.0
      - name: Install go
        uses: actions/setup-go@v5.0.0
        with:
          go-version: ${{ matrix.go-version }}
          check-latest: true
          cache-dependency-path: "**/*.sum"
        id: go

      # Set go bin
      #- name: Setup Go binary path
      #  shell: bash
      #  run: |
      #    echo "GOPATH=${{ github.workspace }}" >> $GITHUB_ENV
      #    echo "${{ github.workspace }}/bin" >> $GITHUB_PATH

      # Fix git line endings
      - name: Git line endings
        shell: bash
        run: |
          git config --global core.autocrlf false
          git config --global core.eol lf

      # Checkout code: https://github.com/actions/checkout/releases/tag/v4.1.1
      - name: Check out main code into the Go module directory
        uses: actions/checkout@v4.1.1
      #  with:
      #    ref: ${{ github.event.pull_request.head.sha }}
      #    path: ${{ github.workspace }}/go/src/github.com/${{ github.repository }}


      # Build using make
      - name: make ${{ matrix.target }}
        shell: bash
        run: |
          make $target
      #  working-directory: ${{ github.workspace }}/go/src/github.com/${{ github.repository }}
        env:
      #    CONFIG_PASSWORD: secretzSoSecureYouWontBelieveIt999
          target: ${{ matrix.target }}
          #          CONFIG_PASSWORD: ${{ secrets.CONFIG_PASSWORD }}
@gedw99 gedw99 changed the title Make Update Github Worklfows to cross OS build ? Jan 17, 2024
@gedw99 gedw99 changed the title Update Github Worklfows to cross OS build ? Add a Github workflow to do cross OS builds. Jan 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant