Skip to content

feat: lock gha uses to digests #75

feat: lock gha uses to digests

feat: lock gha uses to digests #75

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@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Cache Bazel
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
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@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Cache Bazel
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
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@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
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@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- 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@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
- 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