Readme #72
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: Test & Release | |
| on: | |
| push: | |
| branches: | |
| - '**' | |
| tags: | |
| - '**' | |
| pull_request: {} | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: '1.22' | |
| - name: Test | |
| run: make test | |
| - name: Upload coverage | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: go-test-converage | |
| path: | | |
| cover.out | |
| cover.html | |
| build: | |
| needs: test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: '1.22' | |
| - name: Build | |
| run: make build-linux | |
| - name: Upload binary | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dscexporter | |
| path: ./build/linux/dscexporter | |
| check-branch: | |
| name: Check weather the tag exists on the main branch | |
| runs-on: ubuntu-latest | |
| if: ${{ startsWith(github.ref, 'refs/tags/v')}} | |
| outputs: | |
| is_main: ${{ steps.check_step.outputs.is_main }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Fetch full history | |
| - name: Get current branch | |
| id: check_step | |
| run: | | |
| branch=$(git branch --list -r origin/main --contains ${{ github.ref }} | tr -d ' ') | |
| echo $branch | |
| if [[ "$branch" == "origin/main" ]]; then | |
| echo "is_main=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "is_main=false" >> $GITHUB_OUTPUT | |
| fi | |
| upload-release-asset: | |
| needs: | |
| - build | |
| - check-branch | |
| name: Upload Release Asset | |
| runs-on: ubuntu-latest | |
| if: ${{ startsWith(github.ref, 'refs/tags/v') && needs.check-branch.outputs.is_main == 'true' }} | |
| steps: | |
| # - name: Print debug output | |
| # run: | | |
| # echo ${{needs.check-branch.outputs.is_main}} | |
| # echo ${{needs.check-branch.outputs.is_main == 'true'}} | |
| # echo ${{ startsWith(github.ref, 'refs/tags/v')}} | |
| - name: Download binary | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: dscexporter | |
| - name: Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: dscexporter | |