Fix/default bucket #6
Workflow file for this run
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: Main branch | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| types: [closed] | |
| branches: | |
| - master | |
| jobs: | |
| lint-test: | |
| name: Lint and test | |
| uses: ./.github/workflows/lint_and_test.yaml | |
| secrets: inherit | |
| release: | |
| name: Create GitHub Release | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Check if PR was merged | |
| run: | | |
| if [ ${{ github.event_name }} == 'pull_request' ]; then | |
| if [ ${{ github.event.pull_request.merged }} == 'false' ]; then | |
| echo "This PR was closed without merging. Exiting..." | |
| exit 0 | |
| fi | |
| fi | |
| - name: Checkout code | |
| uses: actions/checkout@v3.1.0 | |
| with: | |
| fetch-depth: 0 | |
| - name: TOML Reader | |
| id: read_toml | |
| uses: SebRollen/toml-action@2bd04b06a3ebc3e6a3eb6060de115710cad16cd6 #v1.0.2 | |
| with: | |
| file: 'pyproject.toml' | |
| field: 'project.version' | |
| - name: Define TAG | |
| run: | | |
| export VERSION="${{ steps.read_toml.outputs.value }}" | |
| echo "TAG=v$VERSION" >> $GITHUB_ENV | |
| - name: Check if tag exists | |
| id: check_tag | |
| uses: actions/github-script@v6 | |
| with: | |
| result-encoding: string | |
| script: | | |
| const tag = process.env.TAG; | |
| const { owner, repo } = context.repo; | |
| try { | |
| await github.rest.git.getRef({ | |
| owner, | |
| repo, | |
| ref: `tags/${tag}`, | |
| }); | |
| // If the API call doesn't throw an error, the tag exists | |
| return true; | |
| } catch (error) { | |
| // If the API call throws an error, the tag doesn't exist | |
| return false; | |
| } | |
| env: | |
| TAG: ${{ env.TAG }} | |
| - name: Create Release and Tag | |
| uses: actions/github-script@v6 | |
| with: | |
| result-encoding: string | |
| retries: 3 | |
| script: | | |
| github.rest.repos.createRelease({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| tag_name: process.env.TAG, | |
| target_commitish: context.sha, | |
| name: process.env.TAG, | |
| generate_release_notes: true | |
| }) |