Skip to content

Commit

Permalink
Merge pull request #687 from open-amt-cloud-toolkit/dockerEnhancements
Browse files Browse the repository at this point in the history
ci: update docker build process
  • Loading branch information
madhavilosetty-intel authored Nov 14, 2024
2 parents 3be63a0 + 499fe5f commit aa6b9ed
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 94 deletions.
47 changes: 0 additions & 47 deletions .github/workflows/docker-ci.yml

This file was deleted.

59 changes: 14 additions & 45 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ name: Semantic-Release CI

on:
push:
branches: [ main ]
branches: [main]

permissions:
contents: read

jobs:
release:
permissions:
contents: write # for Git to git push
contents: write # for Git to git push
runs-on: ubuntu-latest
steps:
- name: Harden Runner
Expand All @@ -29,16 +29,21 @@ jobs:
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false

- name: Docker Login
if: ${{ github.ref == 'refs/heads/main' }}
if: ${{ github.ref == 'refs/heads/main' }}
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: vprodemo.azurecr.io
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
logout: true

- name: Docker Login DockerHub
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: docker.io
username: ${{ secrets.INTC_DOCKER_USERNAME }}
password: ${{ secrets.INTC_DOCKER_PASSWORD }}
- name: Install go-licenses
run: |
go install github.com/google/go-licenses@latest
Expand All @@ -47,46 +52,10 @@ jobs:
- name: Semantic Release
uses: cycjimmy/semantic-release-action@b1b432f13acb7768e0c8efdec416d363a57546f2 # v4.1.1
with:
semantic_version: 19.0.5 # It is recommended to specify specifying version range
# for semantic-release.
semantic_version:
19.0.5 # It is recommended to specify specifying version range
# for semantic-release.
extra_plugins: |
@semantic-release/exec@6.0.3
@semantic-release/exec@6.0.3
env:
GITHUB_TOKEN: ${{ secrets.ROSIE_TOKEN }}

# the .nextVersion file will be created by semantic-release
- name: Get Next Version
id: version
run: |
if [ -f .nextVersion ]; then
echo "next=$(cat .nextVersion)" >> "$GITHUB_OUTPUT"
else
echo "next=none" >> "$GITHUB_OUTPUT"
fi
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
if: ${{ steps.version.outputs.next != 'none' }}
with:
repository: open-amt-cloud-toolkit/e2e-testing
ref: docker-release
clean: true
token: ${{ secrets.DOCKER_RELEASE_PAT }}

- name: Create docker-release @ ${{ steps.version.outputs.next }}
if: ${{ steps.version.outputs.next != 'none' }}
env:
RELEASE_YAML: release/rpc-go.yml
NEXT_VERSION: ${{ steps.version.outputs.next }}
run: |
echo "Releasing ${{ github.repository }}@$NEXT_VERSION"
if [ "$NEXT_VERSION" != "" ]; then
CURRENT_VERSION=$(sed -nre 's/(.*):v[0-9]*(([0-9]+\.)*[0-9]+).*/v\2/p' $RELEASE_YAML)
sed -i "s/$CURRENT_VERSION/$NEXT_VERSION/g" $RELEASE_YAML
echo "========================="
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git status
git add .
git commit -m "release(rpc-go): automated release of $NEXT_VERSION @ ${GITHUB_SHA::7}"
git push origin docker-release
fi
2 changes: 1 addition & 1 deletion .releaserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"@semantic-release/exec",
{
"prepareCmd": "./build.sh ${nextRelease.version}",
"publishCmd": "docker push vprodemo.azurecr.io/rpc-go:v${nextRelease.version}",
"publishCmd": "docker push vprodemo.azurecr.io/rpc-go:v${nextRelease.version} && docker push vprodemo.azurecr.io/rpc-go:latest && docker push docker.io/oact-rpc-go:v${nextRelease.version} && docker push docker.io/oact-rpc-go:latest",
"verifyReleaseCmd": "echo v${nextRelease.version} > .nextVersion"
}
],
Expand Down
3 changes: 2 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Get version from the first argument
version=$1

docker build -t vprodemo.azurecr.io/rpc-go:v$version .
docker build -t vprodemo.azurecr.io/rpc-go:v$version vprodemo.azurecr.io/rpc-go:latest -t docker.io/intel/oact-rpc-go:v$version docker.io/intel/oact-rpc-go:latest .


# Build for Linux
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -X 'rpc/pkg/utils.ProjectVersion=$version'" -trimpath -o rpc_linux_x64 ./cmd/main.go
Expand Down

0 comments on commit aa6b9ed

Please sign in to comment.