From d45cb0b2bf92d5c7d63f7efcc6cc1bb34f67feef Mon Sep 17 00:00:00 2001 From: Sergey Nikolaev Date: Sat, 11 Jan 2025 01:28:53 +0700 Subject: [PATCH] feat: better integration with semver tagger --- .github/workflows/release.yml | 41 ++++++++--------------------------- 1 file changed, 9 insertions(+), 32 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fe9f857..31dd93b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 }} @@ -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 @@ -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 @@ -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 }}