|
| 1 | +name: build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "main" ] |
| 6 | + pull_request: |
| 7 | + branches: [ "main" ] |
| 8 | + |
| 9 | +env: |
| 10 | + CARGO_TERM_COLOR: always |
| 11 | + |
| 12 | +jobs: |
| 13 | + build-linux: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + - name: Build |
| 18 | + run: cargo build --release --verbose |
| 19 | + - name: Run tests |
| 20 | + run: cargo test --verbose |
| 21 | + - name: Archive csaf-validator (linux amd64) |
| 22 | + uses: actions/upload-artifact@v4 |
| 23 | + with: |
| 24 | + name: csaf-validator-linux-amd64 |
| 25 | + path: target/csaf-validator |
| 26 | + build-macos: |
| 27 | + runs-on: macos-latest |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@v4 |
| 30 | + - name: Build |
| 31 | + run: cargo build --release --verbose |
| 32 | + - name: Run tests |
| 33 | + run: cargo test --verbose |
| 34 | + - name: Archive csaf-validator (macos arm64) |
| 35 | + uses: actions/upload-artifact@v4 |
| 36 | + with: |
| 37 | + name: csaf-validator-macos-arm64 |
| 38 | + path: target/csaf-validator |
| 39 | + publish: |
| 40 | + runs-on: ubuntu-latest |
| 41 | + needs: |
| 42 | + - build-macos |
| 43 | + - build-linux |
| 44 | + if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, 'beta') && !contains(github.ref, 'alpha') |
| 45 | + steps: |
| 46 | + - name: Determine Version |
| 47 | + run: | |
| 48 | + # determine version from tag |
| 49 | + export VERSION=$(echo "${GITHUB_REF}" | cut -d "/" -f3) |
| 50 | + if [[ $VERSION != v* ]] |
| 51 | + then |
| 52 | + export VERSION="" |
| 53 | + echo "Building version-less (main or feature branch)" |
| 54 | + else |
| 55 | + echo "Building as ${VERSION}" |
| 56 | + fi |
| 57 | + # store version in GitHub environment file |
| 58 | + echo "version=$VERSION" >> $GITHUB_ENV |
| 59 | + - uses: actions/download-artifact@v4 |
| 60 | + with: |
| 61 | + name: csaf-validator-linux-amd64 |
| 62 | + path: . |
| 63 | + - uses: actions/download-artifact@v4 |
| 64 | + with: |
| 65 | + name: csaf-validator-macos-arm64 |
| 66 | + path: . |
| 67 | + - name: Create Release |
| 68 | + id: create_release |
| 69 | + uses: softprops/action-gh-release@v2 |
| 70 | + with: |
| 71 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 72 | + name: ${{ env.version }} |
| 73 | + draft: false |
| 74 | + prerelease: false |
| 75 | + files: | |
| 76 | + csaf-validator-linux-amd64 |
| 77 | + csaf-validator-macos-arm64 |
0 commit comments