Update codecov/codecov-action action to v5 (#918) #4655
This file contains 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 | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- v** | |
pull_request: | |
types: [opened, synchronize, reopened] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-java@v4 | |
with: | |
distribution: "temurin" | |
java-version: 17 | |
- name: Determine Version | |
run: | | |
# determine version from tag | |
export VERSION=$(echo "${GITHUB_REF}" | cut -d "/" -f3) | |
if [[ $VERSION != v* ]] | |
then | |
export VERSION="" | |
echo "Building version-less (master or feature branch)" | |
else | |
# make version more Java-friendly by dropping the 'v' | |
export VERSION=${VERSION:1:${#VERSION}} | |
echo "Building as ${VERSION}" | |
fi | |
# store version in GitHub environment file | |
echo "version=$VERSION" >> $GITHUB_ENV | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v4 | |
- name: Build ${{ env.version }} | |
run: ./gradlew :codyze-cli:build -x check --parallel -Pversion=${{ env.version }} | |
- name: Push Release Docker Image | |
if: startsWith(github.ref, 'refs/tags/v') | |
run: | | |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
docker build -t ghcr.io/fraunhofer-aisec/codyze:latest . | |
docker tag ghcr.io/fraunhofer-aisec/codyze:latest ghcr.io/fraunhofer-aisec/codyze:${{ env.version }} | |
docker push ghcr.io/fraunhofer-aisec/codyze:${{ env.version }} | |
docker push ghcr.io/fraunhofer-aisec/codyze:latest | |
- name: Create Release | |
if: startsWith(github.ref, 'refs/tags/v') | |
uses: softprops/action-gh-release@v2 | |
with: | |
name: ${{ env.version }} | |
generate_release_notes: true | |
files: codyze-cli/build/distributions/codyze-cli-${{ env.version }}.zip |