|
| 1 | +name: Check Version |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ["test", "stage", "main"] |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +env: |
| 9 | + BRANCH: ${{ github.head_ref || github.ref_name }} |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - name: Checkout |
| 16 | + uses: actions/checkout@v3 |
| 17 | + with: |
| 18 | + fetch-depth: 0 |
| 19 | + |
| 20 | + - name: Docker Setup BuildX |
| 21 | + uses: docker/setup-buildx-action@v2 |
| 22 | + |
| 23 | + - name: Bump Patch Version |
| 24 | + run: npm run bump-patch |
| 25 | + if: ${{ env.BRANCH == 'test' }} |
| 26 | + |
| 27 | + - name: Sync Version |
| 28 | + run: npm run sync-version |
| 29 | + if: ${{ env.BRANCH != 'test' }} |
| 30 | + |
| 31 | + - name: Generate Changelog |
| 32 | + run: npm run changelog |
| 33 | + |
| 34 | + - name: Push changes to repo |
| 35 | + run: | |
| 36 | + git config --global user.name ${{ secrets.ADMIN_NAME }} |
| 37 | + git config --global user.email ${{ secrets.ADMIN_EMAIL }} |
| 38 | + git add . |
| 39 | + git commit -m "docs: update version" |
| 40 | + git push |
| 41 | +
|
| 42 | + - name: Load environment variables |
| 43 | + run: | |
| 44 | + awk -v branch="${{ env.BRANCH }}" ' /^[0-9a-zA-Z]+$/ { current_branch = $0; } current_branch == branch && /^[A-Z_]+=/{ print $0; }' release.env >> $GITHUB_ENV |
| 45 | +
|
| 46 | + - name: Set repo |
| 47 | + run: | |
| 48 | + LOWER_CASE_GITHUB_REPOSITORY=$(echo $GITHUB_REPOSITORY | tr '[:upper:]' '[:lower:]') |
| 49 | + echo "DOCKER_TAG_CUSTOM=ghcr.io/${LOWER_CASE_GITHUB_REPOSITORY}:v${{ env.MAJOR }}.${{ env.MINOR }}.${{ env.PATCH }}" >> $GITHUB_ENV |
| 50 | + echo "$GITHUB_ENV" |
| 51 | + |
| 52 | + - name: Build Docker image |
| 53 | + run: | |
| 54 | + echo "Building Docker image for branch: ${{ env.BRANCH }} major: ${{ env.MAJOR }} minor: ${{ env.MINOR }} patch: ${{ env.PATCH }}" |
| 55 | + cd GUI && docker image build --tag $DOCKER_TAG_CUSTOM --no-cache . |
| 56 | + if: ${{ env.BRANCH == 'test' }} |
| 57 | + |
| 58 | + - name: Log in to GitHub container registry |
| 59 | + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin |
| 60 | + |
| 61 | + - name: Push Docker image to GitHub Packages |
| 62 | + run: | |
| 63 | + echo "Pushing Docker image to GitHub Packages" |
| 64 | + docker push $DOCKER_TAG_CUSTOM |
| 65 | + if: ${{ env.BRANCH == 'test' }} |
| 66 | + |
| 67 | + - name: Create Release |
| 68 | + uses: softprops/action-gh-release@v1 |
| 69 | + if: ${{ env.BRANCH == 'main' }} |
| 70 | + with: |
| 71 | + tag_name: v${{ env.MAJOR }}.${{ env.MINOR }}.${{ env.PATCH }} |
| 72 | + generate_release_notes: true |
| 73 | + body_path: ${{ github.workspace }}/CHANGELOG.md |
0 commit comments