forked from onosproject/onos-config
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
233 additions
and
12 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
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 |
---|---|---|
@@ -0,0 +1,190 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# Copyright 2024 Intel Corporation | ||
# Copyright 2024 Kyunghee University | ||
name: GitHub release and Docker images | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
tags: | ||
- v* | ||
|
||
jobs: | ||
push-images: | ||
runs-on: ubuntu-latest | ||
if: github.repository_owner == 'khu-mcl' | ||
env: | ||
REGISTRY: docker.io | ||
DOCKER_REPOSITORY: khusdran/ | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: 'go.mod' | ||
|
||
- run: echo GIT_SHA_SHORT=$(git rev-parse --short HEAD) >> $GITHUB_ENV | ||
|
||
- uses: docker/[email protected] | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Build and push Docker image with tag latest | ||
env: | ||
DOCKER_TAG: latest | ||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | ||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | ||
run: | | ||
git clone https://github.com/onosproject/build-tools.git build/build-tools | ||
make images | ||
make docker-push | ||
# CAUTION: Other actions depend on this name "tag-github" | ||
tag-github: | ||
runs-on: ubuntu-latest | ||
if: github.repository_owner == 'khu-mcl' | ||
outputs: | ||
changed: ${{ steps.version-change.outputs.changed }} | ||
version: ${{ steps.version-change.outputs.version }} | ||
release_branch: ${{ steps.version-change.outputs.release_branch }} | ||
version_branch: ${{ steps.version-change.outputs.version_branch }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Get changes | ||
id: version-file | ||
run: | | ||
if git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep VERSION; then | ||
echo "changed=true" >> $GITHUB_OUTPUT | ||
version_before=$(git show ${{ github.event.before }}:VERSION) | ||
echo "version_before=$version_before" >> $GITHUB_OUTPUT | ||
else | ||
echo "VERSION file was not changed" | ||
fi | ||
- name: Validate change in version file | ||
id: version-change | ||
if: steps.version-file.outputs.changed == 'true' | ||
run: | | ||
version=$(cat VERSION) | ||
version_before_full=${{ steps.version-file.outputs.version_before }} | ||
version_before=${version_before_full::-4} | ||
echo "version=$version" | ||
echo "version_before=$version_before" | ||
validate="^[0-9]+\.[0-9]+\.[0-9]+$" | ||
if [[ $version =~ $validate ]]; then | ||
echo "changed=true" >> $GITHUB_OUTPUT | ||
echo "version=$version" >> $GITHUB_OUTPUT | ||
else | ||
echo "Version change not for release" | ||
fi | ||
if [[ $version_before =~ $validate ]]; then | ||
IFS='.' read -r major minor patch <<< "$version" | ||
IFS='.' read -r major_b minor_b patch_b <<< "$version_before" | ||
if [[ "$major" -ne "$major_b" ]] || [[ "$minor" -ne "$minor_b" ]]; then | ||
version_branch="$major_b.$minor_b" | ||
echo "release_branch=true" >> $GITHUB_OUTPUT | ||
echo "version_branch=$version_branch" >> $GITHUB_OUTPUT | ||
fi | ||
else | ||
echo "Version change not for branch release" | ||
fi | ||
- name: Create release using REST API | ||
if: steps.version-change.outputs.changed == 'true' | ||
run: | | ||
curl -L \ | ||
-X POST \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "Authorization: Bearer ${{ secrets.GH_TOKEN }}" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
https://api.github.com/repos/${{ github.repository }}/releases \ | ||
-d '{ | ||
"tag_name": "v${{ steps.version-change.outputs.version }}", | ||
"target_commitish": "${{ github.event.repository.default_branch }}", | ||
"name": "v${{ steps.version-change.outputs.version }}", | ||
"draft": false, | ||
"prerelease": false, | ||
"generate_release_notes": true | ||
}' | ||
release-image: | ||
runs-on: ubuntu-latest | ||
needs: tag-github | ||
if: needs.tag-github.outputs.changed == 'true' | ||
env: | ||
REGISTRY: docker.io | ||
DOCKER_REPOSITORY: khusdran/ | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: 'go.mod' | ||
|
||
- uses: docker/[email protected] | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Build and push release Docker image | ||
env: | ||
DOCKER_TAG: ${{ needs.tag-github.outputs.version }} | ||
run: | | ||
git clone https://github.com/onosproject/build-tools.git build/build-tools | ||
make images | ||
make docker-push | ||
update-version: | ||
runs-on: ubuntu-latest | ||
needs: tag-github | ||
if: needs.tag-github.outputs.changed == 'true' | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Increment version | ||
run: | | ||
version=${{ needs.tag-github.outputs.version }} | ||
IFS='.' read -r major minor patch <<< "$version" | ||
patch_update=$((patch+1)) | ||
NEW_VERSION="$major.$minor.$patch_update-dev" | ||
echo $NEW_VERSION > VERSION | ||
echo "Updated version: $NEW_VERSION" | ||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v6 | ||
with: | ||
token: ${{ secrets.GH_TOKEN }} | ||
commit-message: Update version | ||
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | ||
author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com> | ||
signoff: false | ||
branch: version-update | ||
delete-branch: true | ||
title: Update version | ||
body: | | ||
Update VERSION file | ||
add-paths: | | ||
VERSION | ||
# branch-release: | ||
# runs-on: ubuntu-latest | ||
# needs: tag-github | ||
# if: (needs.tag-github.outputs.changed == 'true') && (needs.tag-github.outputs.release_branch == 'true') | ||
# env: | ||
# GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | ||
# steps: | ||
# - uses: actions/checkout@v4 | ||
# | ||
# - uses: peterjgrainger/[email protected] | ||
# with: | ||
# branch: "rel-${{ needs.tag-github.outputs.version_branch }}" | ||
# sha: '${{ github.event.pull_request.head.sha }}' |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# Copyright 2024 Intel Corporation | ||
name: Stale issue/pr | ||
|
||
on: | ||
schedule: | ||
- cron: "0 0 * * *" | ||
|
||
env: | ||
DAYS_BEFORE_STALE: 120 | ||
DAYS_BEFORE_CLOSE: 15 | ||
|
||
jobs: | ||
stale: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/stale@v9 | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
stale-issue-message: 'This issue has been stale for ${{ env.DAYS_BEFORE_STALE }} days and will be closed in ${{ env.DAYS_BEFORE_CLOSE }} days. Comment to keep it open.' | ||
stale-pr-message: 'This pull request has been stale for ${{ env.DAYS_BEFORE_STALE }} days and will be closed in ${{ env.DAYS_BEFORE_CLOSE }} days. Comment to keep it open.' | ||
stale-issue-label: 'stale/issue' | ||
stale-pr-label: 'stale/pr' | ||
days-before-stale: ${{ env.DAYS_BEFORE_STALE }} | ||
days-before-close: ${{ env.DAYS_BEFORE_CLOSE }} |
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,6 +1,7 @@ | ||
# SPDX-FileCopyrightText: 2019-present Open Networking Foundation <[email protected]> | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# Copyright 2024 Kyunghee University | ||
|
||
SHELL = bash -e -o pipefail | ||
|
||
|
@@ -9,7 +10,8 @@ export GO111MODULE=on | |
|
||
.PHONY: build | ||
|
||
ONOS_CONFIG_VERSION ?= latest | ||
TARGET := onos-config | ||
DOCKER_TAG ?= latest | ||
|
||
build-tools:=$(shell if [ ! -d "./build/build-tools" ]; then cd build && git clone https://github.com/onosproject/build-tools.git; fi) | ||
include ./build/build-tools/make/onf-common.mk | ||
|
@@ -27,15 +29,15 @@ local-deps: local-helmit local-onos-api local-onos-lib-go local-onos-ric-sdk-go | |
|
||
build: # @HELP build the Go binaries and run all validations (default) | ||
build: mod-update local-deps | ||
go build -mod=vendor -o build/_output/onos-config ./cmd/onos-config | ||
go build -mod=vendor -o build/_output/${TARGET} ./cmd/${TARGET} | ||
|
||
test: # @HELP run the unit tests and source code validation producing a golang style report | ||
test: mod-lint build linters license | ||
go test -race github.com/onosproject/onos-config/... | ||
go test -race github.com/onosproject/${TARGET}/... | ||
|
||
jenkins-test: # @HELP run the unit tests and source code validation producing a junit style report for Jenkins | ||
jenkins-test: mod-lint build linters license | ||
TEST_PACKAGES=github.com/onosproject/onos-config/... ./build/build-tools/build/jenkins/make-unit | ||
TEST_PACKAGES=github.com/onosproject/${TARGET}/... ./build/build-tools/build/jenkins/make-unit | ||
|
||
helmit-config: integration-test-namespace # @HELP run helmit gnmi tests locally | ||
make helmit-config -C test | ||
|
@@ -45,34 +47,37 @@ helmit-rbac: integration-test-namespace # @HELP run helmit gnmi tests locally | |
|
||
integration-tests: helmit-config helmit-rbac # @HELP run helmit integration tests locally | ||
|
||
onos-config-docker: mod-update local-deps # @HELP build onos-config base Docker image | ||
docker build --platform linux/amd64 . -f build/onos-config/Dockerfile \ | ||
-t ${DOCKER_REPOSITORY}onos-config:${ONOS_CONFIG_VERSION} | ||
docke-build: mod-update local-deps # @HELP build onos-config base Docker image | ||
docker build --platform linux/amd64 . -f build/${TARGET}/Dockerfile \ | ||
-t ${DOCKER_REPOSITORY}${TARGET}:${DOCKER_TAG} | ||
|
||
images: # @HELP build all Docker images | ||
images: onos-config-docker | ||
images: build docke-build | ||
|
||
docker-push: | ||
docker push ${DOCKER_REPOSITORY}${TARGET}:${DOCKER_TAG} | ||
|
||
kind: # @HELP build Docker images and add them to the currently configured kind cluster | ||
kind: images kind-only | ||
|
||
kind-only: # @HELP deploy the image without rebuilding first | ||
kind-only: | ||
@if [ "`kind get clusters`" = '' ]; then echo "no kind cluster found" && exit 1; fi | ||
kind load docker-image --name ${KIND_CLUSTER_NAME} ${DOCKER_REPOSITORY}onos-config:${ONOS_CONFIG_VERSION} | ||
kind load docker-image --name ${KIND_CLUSTER_NAME} ${DOCKER_REPOSITORY}${TARGET}:${ONOS_CONFIG_VERSION} | ||
|
||
all: build images | ||
|
||
publish: # @HELP publish version on github and dockerhub | ||
./build/build-tools/publish-version ${VERSION} onosproject/onos-config | ||
./build/build-tools/publish-version ${VERSION} ${DOCKER_REPOSITORY}${TARGET} | ||
|
||
jenkins-publish: jenkins-tools # @HELP Jenkins calls this to publish artifacts | ||
./build/bin/push-images | ||
./build/build-tools/release-merge-commit | ||
./build/build-tools/build/docs/push-docs | ||
|
||
clean:: # @HELP remove all the build artifacts | ||
rm -rf ./build/_output ./vendor ./cmd/onos-config/onos-config ./cmd/onos/onos | ||
go clean -testcache github.com/onosproject/onos-config/... | ||
rm -rf ./build/_output ./vendor ./cmd/${TARGET}/${TARGET} ./cmd/onos/onos | ||
go clean -testcache github.com/onosproject/${TARGET}/... | ||
|
||
local-helmit: # @HELP Copies a local version of the helmit dependency into the vendor directory | ||
ifdef LOCAL_HELMIT | ||
|