From be3ef1abfeb8c082dad887b9a9b5c06c5790f1f2 Mon Sep 17 00:00:00 2001 From: Don Hardman Date: Wed, 15 Jan 2025 11:57:56 +0700 Subject: [PATCH] Use update-semver tagger --- .github/workflows/release.yml | 60 +++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 21 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bab00873..e8e8d0cc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,7 +5,7 @@ on: tags: - 'v*.*.*' branches: - - main + - feature/new-semver env: APP_NAME: 'manticore-buddy' @@ -15,14 +15,31 @@ env: LIBCURL_VERSION: '7.29.0' jobs: + update-version: + runs-on: ubuntu-24.04 + outputs: + version: ${{ steps.semver-tagger.outputs.version }} + version_full: ${{ steps.semver-tagger.outputs.version_full }} + version_rpm: ${{ steps.semver-tagger.outputs.version_rpm }} + version_deb: ${{ steps.semver-tagger.outputs.version_deb }} + target: ${{ steps.semver-tagger.outputs.target }} + permissions: + contents: write + steps: + - id: semver-tagger + uses: manticoresoftware/semver-tagger-action@feature/split-version + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + vars: + needs: update-version + 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 }} + version_full: ${{ steps.vars.outputs.version_full }} + version_rpm: ${{ steps.vars.outputs.version_rpm }} + version_deb: ${{ steps.vars.outputs.version_deb }} steps: - uses: actions/checkout@v3 @@ -30,16 +47,16 @@ jobs: ref: ${{ github.head_ref || github.ref }} - id: vars run: | - version=$(> $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 + echo "version_full=$version_full" >> $GITHUB_OUTPUT + echo "version_rpm=$version_rpm" >> $GITHUB_OUTPUT + echo "version_deb=$version_deb" >> $GITHUB_OUTPUT + echo "target=$target" >> $GITHUB_OUTPUT build-artifact: if: ${{ github.event_name != 'pull_request' }} @@ -60,7 +77,7 @@ jobs: - name: Create artifact run: | - name="${{ env.APP_NAME }}_${{ needs.vars.outputs.app_version }}${{ needs.vars.outputs.rpm_suffix }}" + name="${{ env.APP_NAME }}_${{ needs.vars.outputs.version_full }}" echo "$name" mkdir build/bin cp build/${{ env.APP_NAME }} build/bin/${{ env.APP_NAME }} @@ -101,7 +118,7 @@ jobs: package: ${{ env.APP_NAME }} package_root: .debpkg maintainer: ${{ env.MAINTAINER }} - version: ${{ needs.vars.outputs.app_version }}${{ needs.vars.outputs.deb_suffix }} + version: ${{ needs.vars.outputs.version_deb }} arch: 'all' desc: '${{ env.DESC }}' depends: '${{ env.LIBCURL_NAME }}4 (>= ${{ env.LIBCURL_VERSION}})' @@ -124,7 +141,7 @@ jobs: # Prepare spec file for RPM sed -i 's/{{ NAME }}/${{ env.APP_NAME }}/g' $spec_file - sed -i 's/{{ VERSION }}/${{ needs.vars.outputs.app_version }}${{ needs.vars.outputs.rpm_suffix }}/g' $spec_file + sed -i 's/{{ VERSION }}/${{ needs.vars.outputs.version_rpm }}/g' $spec_file sed -i 's/{{ MAINTAINER }}/${{ env.MAINTAINER }}/g' $spec_file sed -i 's/{{ DESC }}/${{ env.DESC }}/g' $spec_file sed -i 's/{{ LIBCURL_NAME }}/${{ env.LIBCURL_NAME }}/g' $spec_file @@ -142,14 +159,13 @@ jobs: - name: Rename packages to proper name run: | ls -la ./*.rpm - version=${{ needs.vars.outputs.app_version }}${{ needs.vars.outputs.rpm_suffix }} + version=${{ needs.vars.outputs.version_rpm }} rpm_path="./${{ env.APP_NAME }}-${version}-1.noarch.rpm" cp $rpm_path "./${{ env.APP_NAME }}-${version}-1.el7.noarch.rpm" cp $rpm_path "./${{ env.APP_NAME }}-${version}-1.el8.noarch.rpm" cp $rpm_path "./${{ env.APP_NAME }}-${version}-1.el9.noarch.rpm" ls -la ./*.deb - version=${{ needs.vars.outputs.app_version }}${{ needs.vars.outputs.deb_version }} - uses: manticoresoftware/upload_artifact_with_retries@main with: @@ -202,6 +218,8 @@ jobs: needs: - build-artifact - build-linux-packages + env: + target: ${{ needs.vars.outputs.target }} runs-on: ubuntu-22.04 strategy: matrix: @@ -276,5 +294,5 @@ jobs: uses: manticoresoftware/manticoresearch/actions/update-deps@master with: name: buddy - version: "${{ needs.vars.outputs.app_version }} ${{ needs.vars.outputs.app_date }} ${{ needs.vars.outputs.app_commit }}" + version: ${{ needs.vars.outputs.version_full }} token: ${{ secrets.PR_TOKEN }}