diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml new file mode 100644 index 000000000..9e66e2a93 --- /dev/null +++ b/.github/workflows/create-release.yml @@ -0,0 +1,34 @@ +name: Create release +on: + push: + branches: + - master + paths: + - "VERSION" + +permissions: + contents: write + +jobs: + tag-and-release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Read tag from version file + id: version + run: | + if [ ! -f VERSION ]; then + echo "::error::VERSION not found" + exit 1 + fi + TAG_NAME=$(cat VERSION) + echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT + + - name: Create release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ steps.version.outputs.tag_name }} + generate_release_notes: true + make_latest: "true" diff --git a/.github/workflows/release-create-pr.yml b/.github/workflows/release-create-pr.yml new file mode 100644 index 000000000..e4a6c8efa --- /dev/null +++ b/.github/workflows/release-create-pr.yml @@ -0,0 +1,42 @@ +name: Create release PR + +on: + schedule: + - cron: "0 3 * * 1" + workflow_dispatch: + +permissions: + contents: write + pull-requests: write + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v6 + + - name: Increment version + id: version + run: | + DOC_FILE="docs/v3/openapi.json docs/admin/openapi.json" + CLOWDER_FILE=deploy/clowdapp.yaml + VERSION=$(cat VERSION) + [ "$(git log -1 --pretty=%B)" == "$VERSION" ] && exit 0 + RELEASE_TYPE=$(git log -1 | tail -n1) # Check release type (/major, /minor, /patch (default)) + VERSION_NEXT=$(./scripts/increment_version.sh $VERSION $RELEASE_TYPE) + sed -i 's|\("version": "\)[^"]*\("\)$|'"\1$VERSION_NEXT\2|;" $DOC_FILE + echo $VERSION_NEXT > VERSION + echo "VERSION_NEXT=$VERSION_NEXT" >> $GITHUB_OUTPUT + + - name: Create PR for new release + uses: peter-evans/create-pull-request@v8 + if: steps.version.outputs.VERSION_NEXT != '' + with: + base: master + branch: update-semantic-release-${{ steps.version.outputs.VERSION_NEXT }} + commit-message: "Update semantic release to ${{ steps.version.outputs.VERSION_NEXT }}" + title: "Update semantic release to ${{ steps.version.outputs.VERSION_NEXT }}" + token: ${{ secrets.VMAAS_BOT_TOKEN }} + body: | + New semantic release version **${{ steps.version.outputs.VERSION_NEXT }}** is available. diff --git a/.github/workflows/semantic-release.yml b/.github/workflows/semantic-release.yml deleted file mode 100644 index 54897ede8..000000000 --- a/.github/workflows/semantic-release.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Semantic release - -on: - push: - branches: - - master - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - token: ${{ secrets.VMAAS_BOT_TOKEN }} - - name: increment version, commit, push - run: | - DOC_FILE="docs/v3/openapi.json docs/admin/openapi.json" - CLOWDER_FILE=deploy/clowdapp.yaml - VERSION=$(cat VERSION) - [ "$(git log -1 --pretty=%B)" == "$VERSION" ] && exit 0 - RELEASE_TYPE=$(git log -1 | tail -n1) # Check release type (/major, /minor, /patch (default)) - VERSION_NEXT=$(./scripts/increment_version.sh $VERSION $RELEASE_TYPE) - sed -i 's|\("version": "\)[^"]*\("\)$|'"\1$VERSION_NEXT\2|;" $DOC_FILE - echo $VERSION_NEXT >VERSION - git config --global user.name 'semantic-release' - git config --global user.email '' - git commit -am "${VERSION_NEXT}" - git push - git tag ${VERSION_NEXT} - git push origin ${VERSION_NEXT}