add option constellationPath to constellation source depending action pseudo_version

This commit is contained in:
leongross 2022-12-08 13:39:29 +01:00
parent 89cdb56183
commit b899759b16
No known key found for this signature in database
GPG key ID: 8684D89F6BF9B743
3 changed files with 30 additions and 11 deletions

View file

@ -8,6 +8,10 @@ inputs:
description: "Path to the .ko.yaml config file" description: "Path to the .ko.yaml config file"
default: ".ko.yaml" default: ".ko.yaml"
required: false required: false
constellationPath:
description: "Path to the root of the Constellation repo"
#default: "TEST_MICRO_SERVICE_"
required: true
koTarget: koTarget:
description: "Go package to build with ko" description: "Go package to build with ko"
required: true required: true
@ -38,6 +42,8 @@ runs:
- name: Determine pseudo version - name: Determine pseudo version
id: pseudo-version id: pseudo-version
uses: ./.github/actions/pseudo_version uses: ./.github/actions/pseudo_version
with:
constellationPath: ${{ inputs.constellationPath }}
- name: Build and upload container image - name: Build and upload container image
id: build-and-upload id: build-and-upload

View file

@ -1,5 +1,10 @@
name: Determine pseudo version name: Determine pseudo version
description: "Determine go-like pseudo version to use as container image tag." description: "Determine go-like pseudo version to use as container image tag."
inputs:
constellationPath:
description: "Path to Constellation repository root"
#default: "."
required: true
outputs: outputs:
pseudoVersion: pseudoVersion:
@ -25,24 +30,30 @@ runs:
- name: get pseudo version - name: get pseudo version
id: pseudo-version id: pseudo-version
run: | run: |
ln -s ${{ inputs.constellationPath }}/.git .git
if $(git rev-parse --is-shallow-repository); then if $(git rev-parse --is-shallow-repository); then
git fetch --prune --unshallow --tags -v git fetch --prune --unshallow --tags -v
else else
git fetch --tags -v git fetch --tags -v
fi fi
rm .git
pseudoVersionPath=${{ inputs.constellationPath }}/hack/pseudo-version
homedir="$(getent passwd $(id -u) | cut -d ":" -f 6)" homedir="$(getent passwd $(id -u) | cut -d ":" -f 6)"
export GOCACHE=${homedir}/.cache/go-build export GOCACHE=${homedir}/.cache/go-build
export GOPATH=${homedir}/go export GOPATH=${homedir}/go
export GOMODCACHE=${homedir}/.cache/go-mod export GOMODCACHE=${homedir}/.cache/go-mod
pseudoVersion=$(go run .)
semanticVersion=$(go run . -semantic-version) pseudoVersion=$(go run $pseudoVersionPath)
timestamp=$(go run . -print-timestamp) semanticVersion=$(go run $pseudoVersionPath -semantic-version)
branchName=$(go run . -print-branch) timestamp=$(go run $pseudoVersionPath -print-timestamp)
releaseVersion=$(go run . -print-release-branch) branchName=$(go run $pseudoVersionPath -print-branch)
releaseVersion=$(go run $pseudoVersionPath -print-release-branch)
echo "pseudoVersion=${pseudoVersion}" >> $GITHUB_OUTPUT echo "pseudoVersion=${pseudoVersion}" >> $GITHUB_OUTPUT
echo "semanticVersion=${semanticVersion}" >> $GITHUB_OUTPUT echo "semanticVersion=${semanticVersion}" >> $GITHUB_OUTPUT
echo "timestamp=${timestamp}" >> $GITHUB_OUTPUT echo "timestamp=${timestamp}" >> $GITHUB_OUTPUT
echo "branchName=${branchName}" >> $GITHUB_OUTPUT echo "branchName=${branchName}" >> $GITHUB_OUTPUT
echo "releaseVersion=${releaseVersion}" >> $GITHUB_OUTPUT echo "releaseVersion=${releaseVersion}" >> $GITHUB_OUTPUT
working-directory: hack/pseudo-version
shell: bash shell: bash

View file

@ -14,9 +14,6 @@ on:
jobs: jobs:
build-gcp-guest-agent: build-gcp-guest-agent:
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
defaults:
run:
working-directory: ./constellation
permissions: permissions:
contents: read contents: read
packages: write packages: write
@ -47,10 +44,14 @@ jobs:
koData="./guest-agent/kodata" koData="./guest-agent/kodata"
mkdir -p $koData mkdir -p $koData
cp ./constellation/3rdparty/gcp-guest-agent/instance_configs.cfg $koData cp ./constellation/3rdparty/gcp-guest-agent/instance_configs.cfg $koData
cd ${{ github.workspace }}/ cd ${GITHUB_WORKSPACE}/
ls -lah
ln -s ./constellation/.github/ .github ln -s ./constellation/.github/ .github
echo ${{ github.workspace }}/constellation
ls -alh ${{ github.workspace }}/constellation
#echo $GITHUB_WORKSPACE/constellation
#ls -alh $GITHUB_WORKSPACE/constellation
- name: Build and upload gcp guest service container image - name: Build and upload gcp guest service container image
id: build-and-upload id: build-and-upload
# assumes that we are currently in the root of the repo # assumes that we are currently in the root of the repo
@ -59,6 +60,7 @@ jobs:
name: gcp-guest-agent name: gcp-guest-agent
koTarget: ./guest-agent/google-guest-agent/ koTarget: ./guest-agent/google-guest-agent/
githubToken: ${{ secrets.GITHUB_TOKEN }} githubToken: ${{ secrets.GITHUB_TOKEN }}
constellationPath: ${{ github.workspace }}/constellation
cosignPublicKey: ${{ startsWith(github.ref, 'refs/heads/release/v') && secrets.COSIGN_PUBLIC_KEY || secrets.COSIGN_DEV_PUBLIC_KEY }} cosignPublicKey: ${{ startsWith(github.ref, 'refs/heads/release/v') && secrets.COSIGN_PUBLIC_KEY || secrets.COSIGN_DEV_PUBLIC_KEY }}
cosignPrivateKey: ${{ startsWith(github.ref, 'refs/heads/release/v') && secrets.COSIGN_PRIVATE_KEY || secrets.COSIGN_DEV_PRIVATE_KEY }} cosignPrivateKey: ${{ startsWith(github.ref, 'refs/heads/release/v') && secrets.COSIGN_PRIVATE_KEY || secrets.COSIGN_DEV_PRIVATE_KEY }}
cosignPassword: ${{ startsWith(github.ref, 'refs/heads/release/v') && secrets.COSIGN_PASSWORD || secrets.COSIGN_DEV_PASSWORD }} cosignPassword: ${{ startsWith(github.ref, 'refs/heads/release/v') && secrets.COSIGN_PASSWORD || secrets.COSIGN_DEV_PASSWORD }}