Skip to content

Commit

Permalink
build: update major and minor tags update publishing (#22)
Browse files Browse the repository at this point in the history
This PR adds a Github action to update tags automatically after
publishing a new release. Validated in [this job
run](https://github.com/qweeah/setup-oras/actions/runs/6243246594/job/16948534595).

Signed-off-by: Billy Zha <[email protected]>
  • Loading branch information
qweeah authored Sep 20, 2023
1 parent 5810f5f commit ee7dbe1
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/update-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Copyright The ORAS Authors.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Update major and minor tags

on:
release:
types: [published]

jobs:
update-major-minor-tags:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.release.tag_name }}
- name: Git config
run: |
git config user.name github-actions
git config user.email [email protected]
- name: Tag and push new major and minor versions
run: |
VERSION=${{ github.event.release.tag_name }}
MAJOR=$(echo ${VERSION} | cut -d '.' -f 1)
MINOR=${MAJOR}.$(echo ${VERSION} | cut -d '.' -f 2)
if [ -z ${VERSION} ]
then
echo "released tag cannot be empty"
exit 1
else
echo "released tag is ${VERSION}"
fi
if [ -z ${MAJOR} ]
then
echo "major tag cannot be empty"
exit 1
else
echo "major tag is ${MAJOR}"
fi
if [ -z ${MINOR} ]
then
echo "minor tag cannot be empty"
exit 1
else
echo "minor tag is ${MINOR}"
fi
git tag -f ${MAJOR} ${VERSION}
git tag -f ${MINOR} ${VERSION}
git push origin ${MAJOR} --force
git push origin ${MINOR} --force

0 comments on commit ee7dbe1

Please sign in to comment.