-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: James Xin <[email protected]>
- Loading branch information
1 parent
b0e0d18
commit 7f9c660
Showing
1 changed file
with
172 additions
and
170 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,186 +1,188 @@ | ||
name: Go - Continuous Deployment | ||
|
||
env: | ||
TESTING_VERSION: "v0.0.9" | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: "The release version of GLIDE, formatted as v*.*.* or v*.*.*-rc*" | ||
required: true | ||
pkg_go_dev_publish: | ||
description: "Publish to pkg.go.dev" | ||
required: true | ||
type: boolean | ||
default: false | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: "The release version of GLIDE, formatted as v*.*.* or v*.*.*-rc*" | ||
required: true | ||
pkg_go_dev_publish: | ||
description: "Publish to pkg.go.dev" | ||
required: true | ||
type: boolean | ||
default: false | ||
|
||
concurrency: | ||
group: go-cd-${{ github.head_ref || github.ref }} | ||
cancel-in-progress: true | ||
group: go-cd-${{ github.head_ref || github.ref }} | ||
cancel-in-progress: true | ||
|
||
permissions: | ||
id-token: write | ||
id-token: write | ||
|
||
jobs: | ||
load-platform-matrix: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
PLATFORM_MATRIX: ${{ steps.load-platform-matrix.outputs.PLATFORM_MATRIX }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
load-platform-matrix: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
PLATFORM_MATRIX: ${{ steps.load-platform-matrix.outputs.PLATFORM_MATRIX }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: load-platform-matrix | ||
id: load-platform-matrix | ||
shell: bash | ||
run: | | ||
# Get the matrix from the matrix.json file, without the object that has the IMAGE key | ||
export "PLATFORM_MATRIX=$(jq 'map(select(.PACKAGE_MANAGERS | contains(["pkg_go_dev"])))' < .github/json_matrices/build-matrix.json | jq -c .)" | ||
echo "PLATFORM_MATRIX=${PLATFORM_MATRIX}" >> $GITHUB_OUTPUT | ||
- name: load-platform-matrix | ||
id: load-platform-matrix | ||
shell: bash | ||
run: | | ||
# Get the matrix from the matrix.json file, without the object that has the IMAGE key | ||
export "PLATFORM_MATRIX=$(jq 'map(select(.PACKAGE_MANAGERS | contains(["pkg_go_dev"])))' < .github/json_matrices/build-matrix.json | jq -c .)" | ||
echo "PLATFORM_MATRIX=${PLATFORM_MATRIX}" >> $GITHUB_OUTPUT | ||
validate-release-version: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
RELEASE_VERSION: ${{ steps.release-tag.outputs.RELEASE_VERSION }} | ||
steps: | ||
- name: Validate Version Agaisnt RegEx | ||
run: | | ||
echo "input version is: ${{ github.event.inputs.version || env.TESTING_VERSION }}" | ||
if ! echo "${{ github.event.inputs.version || env.TESTING_VERSION }}" | grep -Pq '^v\d+\.\d+\.\d+(-rc\d+)?$'; then | ||
echo "Version is not valid, must be v*.*.* or v*.*.*-rc*" | ||
exit 1 | ||
fi | ||
validate-release-version: | ||
if: ${{ github.event.inputs.pkg_go_dev_publish }} | ||
runs-on: ubuntu-latest | ||
outputs: | ||
RELEASE_VERSION: ${{ steps.release-tag.outputs.RELEASE_VERSION }} | ||
steps: | ||
- name: Validate Version Agaisnt RegEx | ||
run: | | ||
echo "input version is: ${{ github.event.inputs.version }}" | ||
if ! echo "${{ github.event.inputs.version }}" | grep -Pq '^v\d+\.\d+\.\d+(-rc\d+)?$'; then | ||
echo "Version is not valid, must be v*.*.* or v*.*.*-rc*" | ||
exit 1 | ||
fi | ||
- name: Checkout for tag check | ||
uses: actions/checkout@v4 | ||
- name: Checkout for tag check | ||
uses: actions/checkout@v4 | ||
|
||
- name: Validate version agaisnt tags | ||
run: | | ||
git fetch --tags | ||
# testing with default TESTING_VERSION to procceed to follow up jobs | ||
if git tag | grep -q "^go/${{ github.event.inputs.version || env.TESTING_VERSION }}$"; then | ||
echo "Version ${{ github.event.inputs.version || env.TESTING_VERSION }} already exists." | ||
exit 1 | ||
fi | ||
- name: Output release tag | ||
id: release-tag | ||
run: | | ||
echo "RELEASE_VERSION=${{ github.event.inputs.version || env.TESTING_VERSION }}" >> $GITHUB_OUTPUT | ||
- name: Validate version agaisnt tags | ||
run: | | ||
git fetch --tags | ||
if git tag | grep -q "^go/${{ github.event.inputs.version }}$"; then | ||
echo "Version ${{ github.event.inputs.version }} already exists." | ||
exit 1 | ||
fi | ||
- name: Output release tag | ||
id: release-tag | ||
run: | | ||
echo "RELEASE_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT | ||
create-binaries: | ||
needs: [load-platform-matrix, validate-release-version] | ||
if: success() && github.repository_owner == 'valkey-io' | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
host: ${{ fromJson(needs.load-platform-matrix.outputs.PLATFORM_MATRIX)}} | ||
runs-on: ${{ matrix.host.RUNNER}} | ||
steps: | ||
- name: Setup self-hosted runner access | ||
run: | | ||
GHA_HOME=/home/ubuntu/actions-runner/_work/valkey-glide | ||
if [ -d $GHA_HOME ]; then | ||
sudo chown -R $USER:$USER $GHA_HOME | ||
sudo rm -rf $GHA_HOME | ||
mkdir -p $GHA_HOME/valkey-glide | ||
else | ||
echo "No cleaning needed" | ||
fi | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: "^1.22.0" | ||
- name: Install shared software dependencies | ||
uses: ./.github/workflows/install-shared-dependencies | ||
with: | ||
os: ${{ matrix.host.OS }} | ||
target: ${{ matrix.host.TARGET }} | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build Go client | ||
working-directory: go | ||
run: | | ||
make install-build-tools | ||
make build-glide-client | ||
# TODO: move generation of protobuf and header file to a non-matrix step | ||
make generate-protobuf | ||
- name: Upload artifacts | ||
continue-on-error: true | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ matrix.host.TARGET }} | ||
path: | | ||
go/target/release/libglide_rs.a | ||
go/lib.h | ||
go/protobuf/ | ||
create-binaries: | ||
needs: [load-platform-matrix] | ||
if: success() && github.repository_owner == 'valkey-io' | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
host: ${{ fromJson(needs.load-platform-matrix.outputs.PLATFORM_MATRIX) }} | ||
runs-on: ${{ matrix.host.RUNNER }} | ||
steps: | ||
- name: Setup self-hosted runner access | ||
run: | | ||
GHA_HOME=/home/ubuntu/actions-runner/_work/valkey-glide | ||
if [ -d $GHA_HOME ]; then | ||
sudo chown -R $USER:$USER $GHA_HOME | ||
sudo rm -rf $GHA_HOME | ||
mkdir -p $GHA_HOME/valkey-glide | ||
else | ||
echo "No cleaning needed" | ||
fi | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: "^1.22.0" | ||
- name: Install shared software dependencies | ||
uses: ./.github/workflows/install-shared-dependencies | ||
with: | ||
os: ${{ matrix.host.OS }} | ||
target: ${{ matrix.host.TARGET }} | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build Go client | ||
working-directory: go | ||
run: | | ||
make install-build-tools | ||
make build-glide-client | ||
# TODO: move generation of protobuf and header file to a non-matrix step | ||
make generate-protobuf | ||
- name: Upload artifacts | ||
continue-on-error: true | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ matrix.host.TARGET }} | ||
path: | | ||
go/target/release/libglide_rs.a | ||
go/lib.h | ||
go/protobuf/ | ||
commit-auto-gen-files-with-tag: | ||
if: ${{ github.event.inputs.pkg_go_dev_publish }} | ||
needs: [validate-release-version, create-binaries] | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
path: artifacts | ||
- name: Copy generated files to repo | ||
run: | | ||
cd artifacts | ||
for dir in */; do | ||
target_name=${dir%/} | ||
mkdir -p $GITHUB_WORKSPACE/go/rustbin/${target_name} | ||
cp ${target_name}/target/release/libglide_rs.a $GITHUB_WORKSPACE/go/rustbin/${target_name}/ | ||
done | ||
# TODO: move generation of protobuf and header file to a non-matrix step | ||
cd x86_64-unknown-linux-gnu | ||
cp lib.h $GITHUB_WORKSPACE/go/ | ||
mkdir -p $GITHUB_WORKSPACE/go/protobuf | ||
cp protobuf/* $GITHUB_WORKSPACE/go/protobuf/ | ||
- name: Commit and push tag | ||
run: | | ||
git config user.name github-actions | ||
git config user.email [email protected] | ||
git add -f . | ||
git commit -m "Automated commit from GitHub Actions" | ||
git tag go/${{ needs.validate-release-version.outputs.RELEASE_VERSION}} | ||
git push origin go/${{ needs.validate-release-version.outputs.RELEASE_VERSION}} | ||
GOPROXY=proxy.golang.org go list -m github.com/valkey-io/valkey-glide/go@${{ needs.validate-release-version.outputs.RELEASE_VERSION}} | ||
commit-auto-gen-files-with-tag: | ||
if: ${{ github.event.inputs.pkg_go_dev_publish }} | ||
needs: [validate-release-version, create-binaries] | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
path: artifacts | ||
- name: Copy generated files to repo | ||
run: | | ||
cd artifacts | ||
for dir in */; do | ||
target_name=${dir%/} | ||
mkdir -p $GITHUB_WORKSPACE/go/rustbin/${target_name} | ||
cp ${target_name}/target/release/libglide_rs.a $GITHUB_WORKSPACE/go/rustbin/${target_name}/ | ||
done | ||
# TODO: move generation of protobuf and header file to a non-matrix step | ||
cd x86_64-unknown-linux-gnu | ||
cp lib.h $GITHUB_WORKSPACE/go/ | ||
mkdir -p $GITHUB_WORKSPACE/go/protobuf | ||
cp protobuf/* $GITHUB_WORKSPACE/go/protobuf/ | ||
- name: Commit and push tag | ||
run: | | ||
git config user.name github-actions | ||
git config user.email [email protected] | ||
git add -f . | ||
git commit -m "Automated commit from GitHub Actions" | ||
git tag go/${{ needs.validate-release-version.outputs.RELEASE_VERSION }} | ||
git push origin go/${{ needs.validate-release-version.outputs.RELEASE_VERSION }} | ||
GOPROXY=proxy.golang.org go list -m github.com/valkey-io/valkey-glide/go@${{ needs.validate-release-version.outputs.RELEASE_VERSION }} | ||
extra-post-commit-test: | ||
needs: [load-platform-matrix, validate-release-version, commit-auto-gen-files-with-tag] | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
host: ${{ fromJson(needs.load-platform-matrix.outputs.PLATFORM_MATRIX)}} | ||
runs-on: ${{ matrix.host.RUNNER}} | ||
steps: | ||
- name: Setup self-hosted runner access | ||
run: | | ||
GHA_HOME=/home/ubuntu/actions-runner/_work/valkey-glide | ||
if [ -d $GHA_HOME ]; then | ||
sudo chown -R $USER:$USER $GHA_HOME | ||
sudo rm -rf $GHA_HOME | ||
mkdir -p $GHA_HOME/valkey-glide | ||
else | ||
echo "No cleaning needed" | ||
fi | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: 'go/${{ needs.validate-release-version.outputs.RELEASE_VERSION}}' | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: "^1.22.0" | ||
- name: Install shared software dependencies | ||
uses: ./.github/workflows/install-shared-dependencies | ||
with: | ||
os: ${{ matrix.host.OS }} | ||
target: ${{ matrix.host.TARGET }} | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
engine-version: "8.0" | ||
- name: test go at tag | ||
working-directory: go | ||
run: | | ||
make install-tools-go1.22.0 | ||
make -k unit-test integ-test | ||
extra-post-commit-test: | ||
needs: | ||
[ | ||
load-platform-matrix, | ||
validate-release-version, | ||
commit-auto-gen-files-with-tag, | ||
] | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
host: ${{ fromJson(needs.load-platform-matrix.outputs.PLATFORM_MATRIX) }} | ||
runs-on: ${{ matrix.host.RUNNER }} | ||
steps: | ||
- name: Setup self-hosted runner access | ||
run: | | ||
GHA_HOME=/home/ubuntu/actions-runner/_work/valkey-glide | ||
if [ -d $GHA_HOME ]; then | ||
sudo chown -R $USER:$USER $GHA_HOME | ||
sudo rm -rf $GHA_HOME | ||
mkdir -p $GHA_HOME/valkey-glide | ||
else | ||
echo "No cleaning needed" | ||
fi | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: "go/${{ needs.validate-release-version.outputs.RELEASE_VERSION }}" | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: "^1.22.0" | ||
- name: Install shared software dependencies | ||
uses: ./.github/workflows/install-shared-dependencies | ||
with: | ||
os: ${{ matrix.host.OS }} | ||
target: ${{ matrix.host.TARGET }} | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
engine-version: "8.0" | ||
- name: test go at tag | ||
working-directory: go | ||
run: | | ||
make install-tools-go1.22.0 | ||
make -k unit-test integ-test |