Skip to content

Commit

Permalink
Updating Github workflow for tag reading (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
bhogayatakb authored Jul 15, 2024
1 parent aa7f71c commit ca6657a
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 12 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/docker-terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,22 @@ jobs:
with:
images: ghcr.io/middleware-labs/terraform-agent

- name: Setting Release Number
run: |
if [ -n "${{ github.event.inputs.release_version }}" ]; then
echo "RELEASE_VERSION=${{ github.event.inputs.release_version }}" >> $GITHUB_ENV
else
echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
fi
- name: Build and Push
uses: docker/build-push-action@v3
with:
context: ./
file: DockerfileLinux
push: true
platforms: linux/amd64,linux/arm64
build-args: AGENT_VERSION=${{ github.event.inputs.tag || steps.meta.outputs.tags }}
build-args: AGENT_VERSION=$RELEASE_VERSION
tags: |
ghcr.io/middleware-labs/terraform-agent
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/ghcr-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,21 @@ jobs:
username: ${{ secrets.GHCR_USER }}
password: ${{ secrets.GHCR_TOKEN }}

- name: Setting Release Number
run: |
if [ -n "${{ github.event.inputs.release_version }}" ]; then
echo "RELEASE_VERSION=${{ github.event.inputs.release_version }}" >> $GITHUB_ENV
else
echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
fi
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
dockerfile: Dockerfiles/DockerfileWindows
context: .
push: true
tags: |
windows-${{ steps.meta.outputs.tags }}
windows-$RELEASE_VERSION
ghcr.io/middleware-labs/agent-host-go:windows-${{ github.sha }}
platforms: windows/amd64
12 changes: 10 additions & 2 deletions .github/workflows/host-agent-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ jobs:
uses: docker/metadata-action@v4
with:
images: ghcr.io/middleware-labs/mw-host-agent

- name: Setting Release Number
run: |
if [ -n "${{ github.event.inputs.release_version }}" ]; then
echo "RELEASE_VERSION=${{ github.event.inputs.release_version }}" >> $GITHUB_ENV
else
echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
fi
- name: Build and Push
uses: docker/build-push-action@v3
Expand All @@ -68,7 +76,7 @@ jobs:
push: true
platforms: linux/amd64,linux/arm64
build-args: |
AGENT_VERSION=${{ github.event.inputs.tag || steps.meta.outputs.tags }}
AGENT_VERSION=$RELEASE_VERSION
GITHUB_TOKEN=${{ secrets.GHCR_TOKEN }}
tags: |
ghcr.io/middleware-labs/mw-host-agent:${{ github.event.inputs.tag || steps.meta.outputs.tags }}
ghcr.io/middleware-labs/mw-host-agent:$RELEASE_VERSION
6 changes: 5 additions & 1 deletion .github/workflows/host-agent-rpm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ jobs:

- name: Set Architecture Variables
run: |
echo "::set-env name=RELEASE_VERSION::$(echo "${{ github.event.inputs.release_version || steps.meta.outputs.tags }}" | tr -d '\n')"
if [ -n "${{ github.event.inputs.release_version }}" ]; then
echo "RELEASE_VERSION=${{ github.event.inputs.release_version }}" >> $GITHUB_ENV
else
echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
fi
echo "::set-env name=RELEASE_NUMBER::$(echo "${{ github.event.inputs.release_number || 1 }}" | tr -d '\n')"
echo "::set-env name=PACKAGE_NAME::mw-agent"
echo "::set-env name=SPEC_FILE::mw-agent.spec"
Expand Down
16 changes: 12 additions & 4 deletions .github/workflows/host-agent-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,19 @@ jobs:
git config --global url."https://${{ secrets.GHCR_TOKEN }}:@github.com/".insteadOf "https://github.com/"
env:
GITHUB_TOKEN: ${{ secrets.GHCR_TOKEN }}

- name: Setting Release Number
run: |
if [ -n "${{ github.event.inputs.release_version }}" ]; then
echo "RELEASE_VERSION=${{ github.event.inputs.release_version }}" >> $GITHUB_ENV
else
echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
fi
- name: Build MW Agent for Windows
run: |
GOOS=windows CGO_ENABLED=0 GOPRIVATE=github.com/middleware-labs go build -ldflags "-s -w -X main.agentVersion=${{ github.event.inputs.release_version || steps.meta.outputs.tags }}" -o build/mw-windows-agent.exe cmd/host-agent/main.go
makensis -DVERSION=${{ github.event.inputs.release_version || steps.meta.outputs.tags }} package-tooling/windows/package-windows.nsi
GOOS=windows CGO_ENABLED=0 GOPRIVATE=github.com/middleware-labs go build -ldflags "-s -w -X main.agentVersion=$RELEASE_VERSION" -o build/mw-windows-agent.exe cmd/host-agent/main.go
makensis -DVERSION=$RELEASE_VERSION package-tooling/windows/package-windows.nsi
- name: Install jsign Tool For Microsoft Authenticode
run: |
Expand All @@ -62,5 +70,5 @@ jobs:
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: mw-windows-agent-${{ github.event.inputs.release_version || steps.meta.outputs.tags }}-setup.exe
path: package-tooling/windows/mw-windows-agent-${{ github.event.inputs.release_version || steps.meta.outputs.tags }}-setup.exe
name: mw-windows-agent-$RELEASE_VERSION-setup.exe
path: package-tooling/windows/mw-windows-agent-$RELEASE_VERSION-setup.exe
14 changes: 11 additions & 3 deletions .github/workflows/kube-agent-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ jobs:
uses: docker/metadata-action@v4
with:
images: ghcr.io/middleware-labs/mw-kube-agent

- name: Setting Release Number
run: |
if [ -n "${{ github.event.inputs.release_version }}" ]; then
echo "RELEASE_VERSION=${{ github.event.inputs.release_version }}" >> $GITHUB_ENV
else
echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
fi
- name: Build and Push
uses: docker/build-push-action@v3
Expand All @@ -62,8 +70,8 @@ jobs:
push: true
platforms: linux/amd64,linux/arm64
build-args: |
AGENT_VERSION=${{ github.event.inputs.tag || steps.meta.outputs.tags }}
AGENT_VERSION=$RELEASE_VERSION
GITHUB_TOKEN=${{ secrets.GHCR_TOKEN }}
tags: |
ghcr.io/middleware-labs/mw-kube-agent:${{ github.event.inputs.tag || steps.meta.outputs.tags }}
ghcr.io/middleware-labs/agent-kube-go:${{ github.event.inputs.tag || steps.meta.outputs.tags }}
ghcr.io/middleware-labs/mw-kube-agent:$RELEASE_VERSION
ghcr.io/middleware-labs/agent-kube-go:$RELEASE_VERSION

0 comments on commit ca6657a

Please sign in to comment.