Skip to content

Commit

Permalink
Cleanup GitHub actions
Browse files Browse the repository at this point in the history
  • Loading branch information
kiron1 committed Jul 14, 2024
1 parent 334bec0 commit 530fa8d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 34 deletions.
52 changes: 29 additions & 23 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,10 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Fetch dependencies
run: |
bazel build --nobuild --config=ci //pkg:version
- name: Build version
run: |
bazel build --config=ci //:current_version
- name: Version
id: version
run: |
bazel run --config=ci //:current_version | tee -a $GITHUB_OUTPUT
./tools/version | tee -a $GITHUB_OUTPUT
- name: Rev
id: rev
run: |
Expand All @@ -63,6 +57,7 @@ jobs:
- macos
- ubuntu-20.04
# - ubuntu-22.04
# - ubuntu-24.04
# - windows
include:
- build: macos
Expand All @@ -74,34 +69,41 @@ jobs:
# - build: ubuntu-22.04
# os: ubuntu-22.04
# buildflags: --features=negotiate
# - build: ubuntu-24.04
# os: ubuntu-24.04
# buildflags: --features=negotiate
# - build: windows
# os: windows-latest
# buildflags: --features=negotiate

steps:
- name: Git checkout with LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: macOS version
if: ${{ runner.os == 'macOS' }}
run: |
printf 'OS_VER=%s\n' "$(sw_vers --productVersion)" | tee -a $GITHUB_ENV
- name: Linux version
if: ${{ runner.os == 'Linux' }}
run: |
printf 'OS_VER=%s\n' "$(lsb_release --short --release)" | tee -a $GITHUB_ENV
- name: Bazel cache
uses: actions/cache@v4
with:
path: |
~/.cache/bazel_build_cache
~/.cache/bazel_repo_cache
key: ${{ matrix.build }}-bazel-test-${{ hashFiles('Cargo.Bazel.lock', 'WORKSPACE') }}
key: ${{ runner.os }}-${{ env.OS_VER }}-bazel-test-${{ hashFiles('Cargo.Bazel.lock', 'WORKSPACE') }}
restore-keys: |
${{ matrix.build }}-bazel-test-
${{ runner.os }}-${{ env.OS_VER }}-bazel-test-
- name: Setup Windows Bazelrc
# https://bazel.build/configure/windows
run: |
echo "startup --output_user_root=C:/tmp" > ${{ github.workspace }}/user.bazelrc
shell: cmd
if: startswith(matrix.os, 'windows')
if: runner.os == 'Windows'
- name: Install Linux dependency
run: sudo apt-get install libkrb5-dev
if: ${{ startswith(matrix.os, 'ubuntu') }}
Expand All @@ -115,7 +117,7 @@ jobs:
${{ matrix.buildflags }}
"//..."
shell: cmd
if: ${{ startswith(matrix.os, 'windows') }}
if: runner.os == 'Windows'
- name: Run tests
run: >
bazel
Expand All @@ -125,7 +127,7 @@ jobs:
--//:rev=${{ needs.version.outputs.rev }}
${{ matrix.buildflags }}
"//..."
if: ${{ ! startswith(matrix.os, 'windows') }}
if: runner.os != 'Windows'

bazel_build:
name: Package
Expand Down Expand Up @@ -171,29 +173,33 @@ jobs:
# pkgfile: proxydetox-${{ needs.version.outputs.version }}-windows-x86_64.zip

steps:
- name: Git checkout with LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: macOS version
if: ${{ runner.os == 'macOS' }}
run: |
printf 'OS_VER=%s\n' "$(sw_vers --productVersion)" | tee -a $GITHUB_ENV
- name: Linux version
if: ${{ runner.os == 'Linux' }}
run: |
printf 'OS_VER=%s\n' "$(lsb_release --short --release)" | tee -a $GITHUB_ENV
- name: Bazel cache
uses: actions/cache@v4
with:
path: |
~/.cache/bazel_build_cache
~/.cache/bazel_repo_cache
key: ${{ matrix.build }}-bazel-test-${{ hashFiles('Cargo.Bazel.lock', 'WORKSPACE') }}
key: ${{ runner.os }}-${{ env.OS_VER }}-bazel-build-${{ hashFiles('Cargo.Bazel.lock', 'WORKSPACE') }}
restore-keys: |
${{ matrix.build }}-bazel-test-
${{ runner.os }}-${{ env.OS_VER }}-bazel-build-
- name: Setup Windows Bazelrc
# https://bazel.build/configure/windows
run: |
echo "startup --output_user_root=C:/tmp" > ${{ github.workspace }}\user.bazelrc
shell: cmd
if: startswith(matrix.os, 'windows')
if: runner.os == 'Windows'
- name: Install Linux dependency
run: sudo apt-get install libkrb5-dev
if: startswith(matrix.os, 'ubuntu')
Expand Down
17 changes: 6 additions & 11 deletions tools/version
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#!/bin/sh
#!/usr/bin/env bash

set -eu
set -o pipefail

raw=false
prefix="version="

while getopts "r" o; do
case "${o}" in
r)
raw=true
prefix=""
;;
*)
echo "fatal error: invalid arguments"
Expand All @@ -17,11 +18,5 @@ while getopts "r" o; do
done
shift $((OPTIND - 1))

query=$(printf '.packages[] | {name, version} | select(.name == "%s") | .version' "${1:-proxydetox}")
version=$(cargo metadata --format-version 1 --no-deps --offline --quiet | jq -r "${query}")

if "${raw}"; then
echo "${version}"
else
echo "version=${version}" >> "${GITHUB_OUTPUT:-/dev/stdout}"
fi
query=$(printf '"\($prefix)\(.packages[] | {name, version} | select(.name == "%s") | .version)"' "${1:-proxydetox}")
cargo metadata --format-version 1 --no-deps --offline --quiet | jq --arg prefix "${prefix}" -r "${query}"

0 comments on commit 530fa8d

Please sign in to comment.