diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml new file mode 100644 index 000000000..b06c2ef28 --- /dev/null +++ b/.github/workflows/auto-release.yml @@ -0,0 +1,47 @@ +name: Auto-Release +on: + push: + branches: + - develop + workflow_dispatch: + +permissions: + contents: read + +jobs: + semantic-version: + if: false # TODO(CG-10755): merge this with release.yml + name: Semantic version + runs-on: ubuntu-latest + outputs: + tag: ${{ steps.semantic.outputs.release-version }} + permissions: + checks: read # to wait for required checks + contents: write # to be able to publish a GitHub release + issues: write # to be able to comment on released issues + pull-requests: write # to be able to comment on released pull requests + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + # TODO(CG-10743): clean-up once we remove LFS + - name: Remove pre-push hook + run: rm -f .git/hooks/pre-push + + - name: Wait for required checks + uses: poseidon/wait-for-status-checks@v0.6.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + match_pattern: "(unit-tests|integration-tests)" + + - uses: codfish/semantic-release-action@v3 + id: semantic + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + release: + needs: semantic-version + uses: ./.github/workflows/release.yml + with: + tag: ${{ needs.semantic-version.outputs.tag }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ecfcb3f67..919ed5d73 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,15 +1,25 @@ name: Build & Release on: + workflow_call: + inputs: + tag: + required: true + type: string + description: Tag to release + # TODO(CG-10758): create if it does not exist + # workflow_dispatch: + # inputs: + # tag: + # required: true + # type: string + # description: Tag to release # TODO: create if it does not exist push: tags: - v* - branches: - - develop pull_request: branches: - develop - workflow_dispatch: permissions: contents: read @@ -41,7 +51,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - ref: ${{ github.event.pull_request.head.ref || github.ref }} + ref: ${{ inputs.tag || github.event.pull_request.head.ref || github.ref }} - name: Install UV uses: astral-sh/setup-uv@v5.2 @@ -69,71 +79,17 @@ jobs: name: wheels-${{ matrix.os }}-3.${{ matrix.python }} path: ./wheelhouse/*.whl - auto-release: - if: github.ref_name == 'develop' - environment: release + release: + if: ${{ inputs.tag || startsWith(github.ref, 'refs/tags/') }} needs: build runs-on: ubuntu-latest - permissions: - checks: read # to wait for required checks - contents: write # to be able to publish a GitHub release - issues: write # to be able to comment on released issues - pull-requests: write # to be able to comment on released pull requests - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - # TODO(CG-10743): clean-up once we remove LFS - - name: Remove pre-push hook - run: rm -f .git/hooks/pre-push - - - name: Setup environment - uses: ./.github/actions/setup-environment - - - name: Wait for required checks - uses: poseidon/wait-for-status-checks@v0.6.0 - with: - token: ${{ secrets.GITHUB_TOKEN }} - match_pattern: "(unit-tests|integration-tests)" - - - name: Download All Artifacts - uses: actions/download-artifact@v4 - with: - path: dist - merge-multiple: true - pattern: wheels-* - - - name: Github semantic release - uses: codfish/semantic-release-action@v3 - id: semantic - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Release PyPI - if: ${{ steps.semantic.outputs.new-release-published == 'true' }} - uses: ./.github/actions/release-pypi - with: - pypi-token: ${{ secrets.PYPI_TOKEN }} - - - name: Slack notification - if: ${{ steps.semantic.outputs.new-release-published == 'true' }} - uses: ./.github/actions/release-slack-bot - with: - release-tag: ${{ steps.semantic.outputs.release-version }} - slack-token: ${{ secrets.SLACK_BOT_TOKEN }} - - manual-release: - if: startsWith(github.ref, 'refs/tags/') environment: release - needs: build - runs-on: ubuntu-latest permissions: contents: write # grants permission to create a release on github steps: - uses: actions/checkout@v4 - - name: Setup environment + - name: Setup backend uses: ./.github/actions/setup-environment - name: Download All Artifacts @@ -152,9 +108,10 @@ jobs: id: github-release uses: softprops/action-gh-release@v2 with: + tag_name: ${{ inputs.tag || github.ref_name }} files: dist/* fail_on_unmatched_files: true - generate_release_notes: true + generate_release_notes: ${{ startsWith(github.ref, 'refs/tags/') }} - name: Slack notification if: always() diff --git a/package.json b/package.json index df1ef1206..cd7830acd 100644 --- a/package.json +++ b/package.json @@ -5,12 +5,7 @@ "plugins": [ "@semantic-release/commit-analyzer", "@semantic-release/release-notes-generator", - [ - "@semantic-release/github", - { - "assets": ["dist/**"] - } - ] + "@semantic-release/github" ] } }