Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 37 additions & 123 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,133 +1,47 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2024 Intel Corporation
# Copyright 2024 Kyunghee University
name: Publish image and tag/release code
# Copyright 2025 Canonical Ltd.
name: Release Pipeline

on:
push:
branches:
- master
paths:
- "VERSION"

jobs:
version-check:
if: (github.repository_owner == 'onosproject')
runs-on: ubuntu-latest
outputs:
valid_version: ${{ steps.version-check-step.outputs.valid_version }}
dev_version: ${{ steps.dev-version-check-step.outputs.dev_version }}
target_version: ${{ steps.get-target-version-step.outputs.target_version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: check version
id: version-check-step
run: |
make check-version; if [[ $? == 0 ]]; then echo "valid_version=true" >> $GITHUB_OUTPUT; else echo "valid_version=false" >> $GITHUB_OUTPUT; fi
cat $GITHUB_OUTPUT

- name: check dev version
id: dev-version-check-step
run: |
f_dev=$(./build/bin/version_check.sh is_dev)
if [[ $f_dev == "true" ]]; then echo "dev_version=true" >> $GITHUB_OUTPUT; else echo "dev_version=false" >> $GITHUB_OUTPUT; fi
cat $GITHUB_OUTPUT

- name: get target version
id: get-target-version-step
run: |
echo "target_version=$(cat VERSION)" >> $GITHUB_OUTPUT
cat $GITHUB_OUTPUT
permissions:
contents: read

tag_versions:
runs-on: ubuntu-latest
needs: version-check
if: (github.repository_owner == 'onosproject') && (needs.version-check.outputs.valid_version == 'true') && (needs.version-check.outputs.dev_version == 'false')
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: create release using REST API
run: |
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GH_ONOS_PAT }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/releases \
-d '{
"tag_name": "v${{ needs.version-check.outputs.target_version }}",
"target_commitish": "${{ github.event.repository.default_branch }}",
"name": "v${{ needs.version-check.outputs.target_version }}",
"draft": false,
"prerelease": false,
"generate_release_notes": true
}'

publish-images:
runs-on: ubuntu-latest
needs: version-check
if: (github.repository_owner == 'onosproject') && (needs.version-check.outputs.valid_version == 'true')
env:
REGISTRY: docker.io
DOCKER_REPOSITORY: onosproject/
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- uses: docker/login-action@v3.2.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image with tag latest
env:
DOCKER_TAG: latest
run: |
ONOS_CLI_VERSION=${{ env.DOCKER_TAG }} make docker-build
ONOS_CLI_VERSION=${{ env.DOCKER_TAG }} make docker-push
- name: Build and push Docker image with tag
if: needs.version-check.outputs.dev_version == 'false'
env:
DOCKER_TAG: v${{ needs.version-check.outputs.target_version }}
run: |
ONOS_CLI_VERSION=${{ env.DOCKER_TAG }} make docker-build
ONOS_CLI_VERSION=${{ env.DOCKER_TAG }} make docker-push

bump-up-version:
runs-on: ubuntu-latest
needs: version-check
if: (github.repository_owner == 'onosproject') && (needs.version-check.outputs.valid_version == 'true') && (needs.version-check.outputs.dev_version == 'false')
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: increment version
run: |
IFS='.' read -r major minor patch <<< ${{ needs.version-check.outputs.target_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_ONOS_PAT }}
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: true
branch: version-update
delete-branch: true
title: Update version
body: |
Update VERSION file
add-paths: |
VERSION
jobs:
# Tag GitHub Release
# The convention is to prefix the version with a 'v', e.g., v1.2.3
tag-github:
uses: onosproject/.github/.github/workflows/tag-github.yml@main
with:
add_v: true
secrets: inherit

# Build and Release Docker Image
# The convention is to use the same tag for the Docker image as the GitHub Release
release-image:
needs: tag-github
if: needs.tag-github.outputs.changed == 'true'
permissions:
contents: read
packages: write
actions: read
id-token: write
attestations: write
uses: onosproject/.github/.github/workflows/release-image.yml@main
with:
docker_tag: ${{ needs.tag-github.outputs.version }}
secrets: inherit

# Bump Version
update-version:
needs: tag-github
if: needs.tag-github.outputs.changed == 'true'
uses: onosproject/.github/.github/workflows/bump-version.yml@main
secrets: inherit
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ export GO111MODULE=on

.PHONY: build license

ONOS_CLI_VERSION ?= latest
ONOS_CLI_VERSION ?= latest
DOCKER_TAG ?= ${ONOS_CLI_VERSION}
DOCKER_REPOSITORY ?= onosproject/
DOCKER_REGISTRY ?= ""
DOCKER_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}onos-cli:${DOCKER_TAG}

GOLANG_CI_VERSION := v1.52.2

Expand All @@ -31,14 +35,14 @@ docs:
docker-build-onos-cli: # @HELP build onos CLI Docker image
@go mod vendor
docker build . -f build/onos/Dockerfile \
-t onosproject/onos-cli:${ONOS_CLI_VERSION}
-t ${DOCKER_IMAGENAME}
@rm -rf vendor

docker-build: # @HELP build all Docker images
docker-build: build docker-build-onos-cli

docker-push-onos-cli: # @HELP push onos-cli Docker image
docker push onosproject/onos-cli:${ONOS_CLI_VERSION}
docker push ${DOCKER_IMAGENAME}

docker-push: # @HELP push docker images
docker-push: docker-push-onos-cli
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.9.39-dev
0.9.39