Skip to content

ci: Simplify for taking version of go from go.mod #535

ci: Simplify for taking version of go from go.mod

ci: Simplify for taking version of go from go.mod #535

Workflow file for this run

name: cross-building
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
jobs:
build:
strategy:
fail-fast: false
matrix:
goos:
- linux
- darwin
- windows
runs-on: ubuntu-latest
continue-on-error: true
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Avoid running against a shallow clone
- uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }} # We plan to run only against internal pull requests
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0 # Avoid running against a shallow clone
- name: Force fetch upstream tags
run: git fetch --force --tags
- name: Set up Go ${{ matrix.go }}
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Print environment
id: vars
run: |
printf "Using Go at $(which go) (version $(go version))\n"
printf "\n\nGo environment:\n\n"
go env
printf "\n\nSystem environment:\n\n"
env
- name: Build the make/make tool
run: go build -o make/make make/main.go
- name: Build
env:
GOOS: ${{ matrix.goos }}
CGO_ENABLED: 0
shell: bash
run: |
make/make GOOS=$GOOS lstn
- name: Generate docs
if: ${{ github.event_name == 'pull_request' && matrix.goos == 'linux' }}
run: |
GITHUB_ACTIONS= GITHUB_EVENT_PATH= ./lstn manual 2> docs/cheatsheet.md
./lstn config 2> docs/configuration.md
./lstn env 2> docs/environment.md
./lstn exit 2> docs/exitcodes.md
./lstn reporters 2> docs/reporters.md
- name: Update docs
if: ${{ github.event_name == 'pull_request' && matrix.goos == 'linux' }}
uses: EndBug/add-and-commit@v9
with:
default_author: github_actor
commit: --signoff
add: "docs"
message: "docs: update autogenerated docs"
push: true
- name: Archive the artifact(s) for ${{ matrix.goos }}
if: ${{ matrix.goos != 'windows' }}
uses: actions/upload-artifact@v4
with:
name: artifact-${{ matrix.goos }}
path: ./lstn
retention-days: 1
- name: Archive the artifact(s) for windows
if: ${{ matrix.goos == 'windows' }}
uses: actions/upload-artifact@v4
with:
name: artifact-${{ matrix.goos }}
path: ./lstn.exe
retention-days: 1
version-darwin:
name: "check version (darwin)"
needs: build
runs-on: macos-latest
steps:
- name: Check out the source code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Avoid running against a shallow clone
- name: Get binaries
uses: actions/download-artifact@v4
with:
name: artifact-darwin
path: .
- name: Check short version
shell: bash
run: |
file lstn
chmod +x lstn
./lstn version
latest_tag=$(git for-each-ref --sort=-creatordate --count 1 --format="%(refname:short)" "refs/tags/v*")
[[ "lstn ${latest_tag}" == $(./lstn version 2>&1) ]]
version-linux:
name: "check version (linux)"
needs: build
runs-on: ubuntu-latest
steps:
- name: Check out the source code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Avoid running against a shallow clone
- name: Get binaries
uses: actions/download-artifact@v4
with:
name: artifact-linux
path: .
- name: Check short version
shell: bash
run: |
file lstn
chmod +x lstn
./lstn version
latest_tag=$(git for-each-ref --sort=-creatordate --count 1 --format="%(refname:short)" "refs/tags/v*")
[[ "lstn ${latest_tag}" == $(./lstn version 2>&1) ]]
version-windows:
name: "check version (windows)"
needs: build
runs-on: windows-latest
steps:
- name: Check out the source code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Avoid running against a shallow clone
- name: Get binaries
uses: actions/download-artifact@v4
with:
name: artifact-windows
path: .
# TODO: equality
- name: Check short version
run: |
file lstn.exe
.\lstn.exe version