Update README.md #28
Workflow file for this run
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: Test, Build, maybe Release | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- 'v*' | |
pull_request: | |
branches: | |
- main | |
jobs: | |
Test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out tdiscuss | |
uses: actions/checkout@v4 | |
- name: Cache Bazel | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cache/bazel | |
key: ${{ runner.os }}-bazel-${{ hashFiles('.bazelversion', '.bazelrc', 'MODULE.bazel') }} | |
restore-keys: | | |
${{ runner.os }}-bazel- | |
- name: Go version check | |
run: make check-go-versions | |
- name: Test //... | |
run: bazelisk test --workspace_status_command="${PWD}/status.sh" //... | |
Build: | |
needs: Test | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
goos: [darwin, linux] | |
goarch: [amd64, arm64] | |
steps: | |
- name: Check out tdiscuss | |
uses: actions/checkout@v4 | |
- name: Cache Bazel | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cache/bazel | |
key: ${{ runner.os }}-bazel-${{ hashFiles('.bazelversion', '.bazelrc', 'MODULE.bazel') }} | |
restore-keys: | | |
${{ runner.os }}-bazel- | |
- name: Build //:tdiscuss-${{ matrix.goos }}-${{ matrix.goarch }} | |
run: | | |
bazelisk build --stamp --workspace_status_command="${PWD}/status.sh" //:tdiscuss-${{ matrix.goos }}-${{ matrix.goarch }} | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: tdiscuss-${{ matrix.goos }}-${{ matrix.goarch }} | |
path: bazel-bin/tdiscuss-${{ matrix.goos }}-${{ matrix.goarch }}_/tdiscuss-${{ matrix.goos }}-${{ matrix.goarch }} | |
Release: | |
needs: Build | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags/v') | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set pre-release flag | |
id: release_type | |
run: | | |
if [[ ${{ github.ref }} == *beta* ]]; then | |
echo "type=pre-release" >> $GITHUB_OUTPUT | |
else | |
echo "type=release" >> $GITHUB_OUTPUT | |
fi | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
- name: Create Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
if [[ "${{ steps.release_type.outputs.type }}" == "pre-release" ]]; then | |
gh release create ${GITHUB_REF#refs/tags/} \ | |
--title "Release ${GITHUB_REF#refs/tags/}" \ | |
--prerelease \ | |
--generate-notes | |
else | |
gh release create ${GITHUB_REF#refs/tags/} \ | |
--title "Release ${GITHUB_REF#refs/tags/}" \ | |
--generate-notes | |
fi | |
- name: Upload Release Assets | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
for artifact in tdiscuss-*; do | |
gh release upload ${GITHUB_REF#refs/tags/} $artifact/$artifact | |
done |