V 1.0.0 #10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Release | |
| permissions: | |
| contents: write | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| build-and-release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Get commit message | |
| id: commit_message | |
| run: echo "MESSAGE=$(git log -1 --pretty=%B)" >> $GITHUB_ENV | |
| - name: Check if commit message is a version tag | |
| id: check_version | |
| run: | | |
| if [[ "${{ env.MESSAGE }}" =~ ^V\ [0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| VERSION=$(echo "${{ env.MESSAGE }}" | awk '{print $2}') | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| echo "MATCH=1" >> $GITHUB_ENV | |
| else | |
| echo "MATCH=0" >> $GITHUB_ENV | |
| fi | |
| - name: Stop if no valid version tag | |
| if: env.MATCH != '1' | |
| run: echo "Commit message does not contain a valid version tag. Skipping release." && exit 0 | |
| - name: Install dependencies | |
| run: sudo apt update && sudo apt install -y build-essential libssl-dev libboost-all-dev | |
| - name: Compile the project | |
| run: | | |
| make | |
| g++ sdhash-src/sdhash.o sdhash-src/sdhash_threads.o libsdbf.a -o JC-sdhash -fopenmp \ | |
| -L. -L./external/stage/lib -L/usr/lib/x86_64-linux-gnu \ | |
| -lboost_system -lboost_filesystem -lboost_program_options -lc -lm -lcrypto -lboost_thread -lpthread | |
| mv JC-sdhash SDhash | |
| ls -lah | |
| - name: Create Git Tag | |
| run: | | |
| git config user.name "GitHub Actions" | |
| git config user.email "actions@github.com" | |
| git tag ${{ env.VERSION }} | |
| git push origin ${{ env.VERSION }} | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: ./SDhash | |
| tag_name: ${{ env.VERSION }} | |
| name: "Release ${{ env.VERSION }}" | |
| body: "Automated release for commit ${{ github.sha }}" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |