Create Release #20
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: Create Release | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| release: | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| id-token: write | |
| checks: write | |
| runs-on: ubuntu-latest | |
| outputs: | |
| new-tag: ${{ steps.assign.outputs.NEW_TAG }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Fetch all commits and tags | |
| - name: Get last non-pre-release tag | |
| id: last-release-tag | |
| run: | | |
| # Fetch all tags and filter for non-pre-release tags | |
| non_pre_release_tags=$(git tag --list 'v[0-9]*.[0-9]*.[0-9]*' --sort=-v:refname) | |
| # Get the last non-pre-release tag | |
| last_non_pre_release_tag=$(echo "$non_pre_release_tags" | head -n 1) | |
| if [ -z "$last_non_pre_release_tag" ]; then | |
| # If no non-pre-release tags found, get the last pre-release tag | |
| last_pre_release_tag=$(git tag --list 'v[0-9]*.[0-9]*.[0-9]*-rc.*' --sort=-v:refname | head -n 1) | |
| if [ -z "$last_pre_release_tag" ]; then | |
| # If no tags found at all, create the initial version | |
| new_tag="v0.0.1" | |
| else | |
| # Extract major, minor, and patch components from the last pre-release tag | |
| IFS='.' read -r major minor patch rc_number <<< "$last_pre_release_tag" | |
| # Remove the -rc suffix | |
| new_tag="v$major.$minor.$patch" | |
| fi | |
| else | |
| # Extract major, minor, and patch components from the last non-pre-release tag | |
| IFS='.' read -r major minor patch <<< "$last_non_pre_release_tag" | |
| # Increment the patch version | |
| incremented_patch=$((patch + 1)) | |
| new_tag="$major.$minor.$incremented_patch" | |
| fi | |
| echo "Last non-pre-release tag: $last_non_pre_release_tag" | |
| echo "New tag: $new_tag" | |
| echo "::set-output name=new_tag::$new_tag" | |
| - id: assign | |
| name: Set environment variable | |
| run: echo "NEW_TAG=${{ steps.last-release-tag.outputs.new_tag }}" >> "$GITHUB_OUTPUT" | |
| - uses: release-drafter/release-drafter@v6 | |
| with: | |
| tag: ${{ steps.last-release-tag.outputs.new_tag }} | |
| name: ${{ steps.last-release-tag.outputs.new_tag }} | |
| version: ${{ steps.last-release-tag.outputs.new_tag }} | |
| publish: true | |
| - uses: danielchabr/[email protected] | |
| with: | |
| hasSome: breaking change,feature,bug,style,refactor,test,chore,docs,documentation,ci,dependencies,enhancement, | |
| githubToken: ${{ secrets.GITHUB_TOKEN }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| backend: | |
| name: Add backend binaries to this release | |
| runs-on: ubuntu-latest | |
| needs: release | |
| defaults: | |
| run: | |
| working-directory: 'backend' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| # Disabling shallow clones is recommended for improving the relevancy of reporting | |
| fetch-depth: 0 | |
| - name: Display used tag | |
| run: echo "Release tag is ${{needs.release.outputs.new-tag}}" | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| cache: maven | |
| - name: Build with Maven | |
| run: mvn -B package --file pom.xml -DskipTests | |
| - name: Upload backend binaries to release | |
| uses: svenstaro/upload-release-action@v2 | |
| with: | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| file: backend/kendo-tournament-rest/target/kendo-tournament-backend.jar | |
| asset_name: kendo-tournament-backend.jar | |
| tag: ${{needs.release.outputs.new-tag}} | |
| overwrite: true | |
| draft: false | |
| frontend: | |
| name: Add frontend files to this release | |
| runs-on: ubuntu-latest | |
| needs: release | |
| defaults: | |
| run: | |
| working-directory: 'frontend' | |
| strategy: | |
| matrix: | |
| node-version: [ 18.x ] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| # Disabling shallow clones is recommended for improving the relevancy of reporting | |
| fetch-depth: 0 | |
| - name: Display used tag | |
| run: echo "Release tag is ${{needs.release.outputs.new-tag}}" | |
| - name: Use Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: 'npm' | |
| cache-dependency-path: '**/package-lock.json' | |
| - name: Install Angular | |
| run: npm i -g @angular/cli | |
| - name: npm dependencies | |
| run: npm install | |
| - name: Checking node | |
| run: node -v | |
| # Docker Resource | |
| - name: Building docker resources | |
| run: ng build --configuration docker --output-hashing=all | |
| - name: zip docker resource | |
| run: | | |
| rm -f dist/kendo-tournament-frontend-docker.zip | |
| zip -r dist/kendo-tournament-frontend-docker.zip dist/frontend | |
| - name: Upload docker frontend code to release | |
| uses: svenstaro/upload-release-action@v2 | |
| with: | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| file: frontend/dist/kendo-tournament-frontend-docker.zip | |
| asset_name: kendo-tournament-frontend-docker.zip | |
| tag: ${{needs.release.outputs.new-tag}} | |
| overwrite: true | |
| draft: false | |
| # Basic Resource | |
| - name: Building basic resources | |
| run: ng build --configuration production --output-hashing=all | |
| - name: zip basic resource | |
| run: | | |
| rm -f dist/kendo-tournament-frontend.zip | |
| zip -r dist/kendo-tournament-frontend.zip dist/frontend | |
| - name: Upload frontend code to release | |
| uses: svenstaro/upload-release-action@v2 | |
| with: | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| file: frontend/dist/kendo-tournament-frontend.zip | |
| asset_name: kendo-tournament-frontend.zip | |
| tag: ${{needs.release.outputs.new-tag}} | |
| overwrite: true | |
| draft: false | |