CI: Bump actions #61
This file contains 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: CI | |
on: | |
- push | |
- pull_request | |
jobs: | |
build-ubuntu: | |
name: Build on Ubuntu x86_64 with ${{ matrix.CC }} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
CC: | |
- gcc | |
- clang | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install build dependencies | |
run: sudo apt-get install asciidoctor | |
- run: make build CC=${{ matrix.CC }} | |
- run: ./build/tty-copy -V | |
- run: make install DESTDIR=dest | |
build-alpine: | |
name: Build on Alpine ${{ matrix.ARCH }} with ${{ matrix.CC }} ${{ matrix.LDFLAGS }} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
ARCH: | |
- x86_64 | |
- aarch64 | |
- armv7 | |
- ppc64le | |
- riscv64 | |
CC: | |
- gcc | |
LDFLAGS: | |
- '' | |
- -static -s | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # fetch all history | |
- name: Install latest Alpine Linux for ${{ matrix.ARCH }} | |
uses: jirutka/setup-alpine@v1 | |
with: | |
arch: ${{ matrix.ARCH }} | |
branch: ${{ matrix.ARCH == 'riscv64' && 'edge' || 'latest-stable' }} | |
packages: asciidoctor build-base | |
- name: Get version | |
run: | | |
GIT_TAG=$(git describe --tags --match 'v*' 2>/dev/null || echo ${GITHUB_REF##*/}) | |
echo "VERSION=${GIT_TAG#v}" >> $GITHUB_ENV | |
- name: Build tty-copy | |
run: | | |
make build CC=${{ matrix.CC }} LDFLAGS="${{ matrix.LDFLAGS }}" VERSION="${{ env.VERSION }}" | |
ls -lah build/ | |
file build/tty-copy | |
shell: alpine.sh {0} | |
- name: tty-copy -V | |
run: ./build/tty-copy -V | |
shell: alpine.sh {0} | |
- name: Rename binary before upload | |
if: ${{ matrix.LDFLAGS != '' }} | |
run: | | |
mkdir dist | |
cp -a build/tty-copy dist/tty-copy.${{ matrix.ARCH }}-linux | |
- name: Upload binary to artifacts | |
if: ${{ matrix.LDFLAGS != '' }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: binaries | |
path: dist/* | |
if-no-files-found: error | |
build-macos: | |
name: Build on macOS x86_64 | |
runs-on: macos-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # fetch all history | |
- name: Install dependencies | |
run: brew install asciidoctor | |
- name: Get version | |
run: | | |
GIT_TAG=$(git describe --tags --match 'v*' 2>/dev/null || echo ${GITHUB_REF##*/}) | |
echo "VERSION=${GIT_TAG#v}" >> $GITHUB_ENV | |
- name: Build tty-copy | |
run: | | |
make build VERSION="${{ env.VERSION }}" | |
ls -lah build/ | |
file build/tty-copy | |
- name: tty-copy -V | |
run: ./build/tty-copy -V | |
- run: make install DESTDIR=dest | |
- name: Rename binary before upload | |
run: | | |
mkdir dist | |
cp -a build/tty-copy dist/tty-copy.x86_64-darwin | |
- name: Upload binary to artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: binaries | |
path: dist/* | |
if-no-files-found: error | |
publish: | |
name: Publish binaries to Releases | |
if: ${{ startsWith(github.ref, 'refs/tags/v') && github.event_name != 'pull_request' }} | |
needs: | |
- build-alpine | |
- build-macos | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Download binaries from artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: dist | |
merge-multiple: true | |
- name: Generate checksums.txt | |
run: | |
shasum -a 256 * > checksums.txt | |
working-directory: binaries | |
- name: Upload binaries to Releases | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: binaries/* | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |