Skip to content

Commit

Permalink
Created tags with version prefixes (#151)
Browse files Browse the repository at this point in the history
* begining

* final?

* fix

* wirete all

* tagpro

* safeguards

* fix

* fix

---------

Co-authored-by: MarconZet <user.name>
  • Loading branch information
MarconZet authored Feb 23, 2023
1 parent ae1e1cf commit 1ddf0c7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: ./
- uses: VirtusLab/bazel-steward@latest
with:
github-personal-token: ${{ secrets.PAT_GITHUB_TOKEN }}
25 changes: 23 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Release
on:
push:
tags:
- "v*"
- "v*.*.*"
branches: [ main ]

jobs:
Expand All @@ -23,4 +23,25 @@ jobs:
prerelease: ${{ github.ref_type != 'tag' }}
title: ${{ github.ref_type != 'tag' && 'Development Build' || null }}
automatic_release_tag: ${{ github.ref_type != 'tag' && 'latest' || null }}
files: bazel-steward.jar
files: bazel-steward.jar
prefix-version-tag:
runs-on: "ubuntu-latest"
if: github.ref_type == 'tag'
needs: tagged-release
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- run: |
set -x
GIT_TAG=$(echo "${{ github.event.ref }}" | grep -Eo 'v[\.0-9]*')
MINOR_TAG=$(echo "$GIT_TAG" | grep -Eo 'v[0-9]+\.[0-9]+')
MAJOR_TAG=$(echo "$GIT_TAG" | grep -Eo 'v[0-9]+')
for TAG in "$MINOR_TAG" "$MAJOR_TAG"
do
TAG_LATEST=$(git ls-remote --tags | grep -Eo "v[0-9]+\.[0-9]+\.[0-9]+" | grep -E "$TAG" | sort -Vr | head -n 1)
if [ "$GIT_TAG" == "$TAG_LATEST" ]; then
git tag -f "$TAG" "$GIT_TAG"
git push -f origin "$TAG"
fi
done
11 changes: 9 additions & 2 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,17 @@ runs:
- name: Download release
if: ${{ inputs.use-release == 'true' }}
run: |
TAG_NAME=$(echo "${{ github.action_path }}" | grep -Po "(?<=\/)[^\/]*$")
gh release download $TAG_NAME --pattern bazel-steward.jar --repo VirtusLab/bazel-steward
TAG_PATTERN=$(echo "${{ github.action_path }}" | grep -Po "(?<=\/)[^\/]*$")
if [[ $TAG_PATTERN == v* ]] ;
then
TAG_NAME=$(gh release list -L 100 --repo $REPOSITORY | grep -Eo '^'"$TAG_PATTERN"'[\.0-9]*' | sort -Vr | head -n 1)
else
TAG_NAME=$TAG_PATTERN
fi
gh release download $TAG_NAME --pattern bazel-steward.jar --repo $REPOSITORY
env:
GH_TOKEN: ${{ github.token }}
REPOSITORY: VirtusLab/bazel-steward
shell: bash
- name: Build jar file
if: ${{ inputs.use-release != 'true' }}
Expand Down

0 comments on commit 1ddf0c7

Please sign in to comment.