Skip to content

Commit

Permalink
Merge pull request #5 from manticoresoftware/jan11
Browse files Browse the repository at this point in the history
feat: better integration with semver tagger
  • Loading branch information
sanikolaev authored Jan 10, 2025
2 parents 67d02b2 + d45cb0b commit 29f227d
Showing 1 changed file with 9 additions and 32 deletions.
41 changes: 9 additions & 32 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,23 @@ jobs:
update-version:
runs-on: ubuntu-24.04
outputs:
has_tag: ${{ steps.check-tag.outputs.has_tag }}
version: ${{ steps.semver-tagger.outputs.version }}
version_full: ${{ steps.semver-tagger.outputs.version_full }}
target: ${{ steps.semver-tagger.outputs.target }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- id: semver-tagger
uses: manticoresoftware/semver-tagger-action@main
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Check version tag
id: check-tag
run: |
if git tag --points-at HEAD | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' > /dev/null; then
echo "has_tag=true" >> $GITHUB_OUTPUT
else
echo "has_tag=false" >> $GITHUB_OUTPUT
fi

vars:
needs: update-version
if: needs.update-version.outputs.has_tag == 'true'
if: ${{ needs.update-version.outputs.version != '' }}
runs-on: ubuntu-22.04
outputs:
app_version: ${{ steps.vars.outputs.app_version }}
app_date: ${{ steps.vars.outputs.app_date }}
app_commit: ${{ steps.vars.outputs.app_commit }}
rpm_suffix: ${{ steps.vars.outputs.rpm_suffix }}
deb_suffix: ${{ steps.vars.outputs.deb_suffix }}
target: ${{ steps.vars.outputs.target }}
Expand All @@ -53,28 +42,15 @@ jobs:
fetch-depth: 0
- id: vars
run: |
# Get version from git tag
if ! version=$(git describe --tags --exact-match --match '[0-9]*.[0-9]*.[0-9]*' 2>/dev/null); then
echo "Error: Current commit must be tagged with version in format x.y.z. The actual tag is $version"
exit 1
fi
# Check if commit has 'release' tag
if git describe --tags --exact-match --match 'release' >/dev/null 2>&1; then
version="${version}"
target="release"
else
version="${version}+dev"
target="dev"
fi
# Use version and target from update-version job
version="${{ needs.update-version.outputs.version_full }}"
target="${{ needs.update-version.outputs.target }}"
date=$( date +%y%m%d%H )
commit=${GITHUB_SHA:0:7}
echo "app_version=$version" >> $GITHUB_OUTPUT
echo "target=$target" >> $GITHUB_OUTPUT
echo "app_date=$date" >> $GITHUB_OUTPUT
echo "app_commit=$commit" >> $GITHUB_OUTPUT
echo "rpm_suffix=_${date}.$commit" >> $GITHUB_OUTPUT
echo "deb_suffix=-${date}-$commit" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -118,6 +94,7 @@ jobs:
cp -r ${{ env.APP_NAME }} .debpkg/usr/bin/${{ env.APP_NAME }}
cp -r ${{ env.APP_NAME }} .rpmpkg/usr/bin/${{ env.APP_NAME }}
cp -p LICENSE .rpmpkg/usr/share/manticore/modules/${{ env.APP_NAME }}/LICENSE
echo "${{ needs.vars.outputs.app_version }}" > .debpkg/usr/share/manticore/modules/${{ env.APP_NAME }}/APP_VERSION
echo "${{ needs.vars.outputs.app_version }}" > .rpmpkg/usr/share/manticore/modules/${{ env.APP_NAME }}/APP_VERSION
cp -p README.md .rpmpkg/usr/share/manticore/modules/${{ env.APP_NAME }}/README.md
sudo chown -R root:root .debpkg
Expand Down Expand Up @@ -279,5 +256,5 @@ jobs:
uses: manticoresoftware/manticoresearch/actions/update-deps@master
with:
name: load
version: "${{ needs.vars.outputs.app_version }} ${{ needs.vars.outputs.app_date }} ${{ needs.vars.outputs.app_commit }}"
version: "${{ needs.vars.outputs.app_version }}"
token: ${{ secrets.PR_TOKEN }}

0 comments on commit 29f227d

Please sign in to comment.