|
| 1 | +name: Release mcp-lambda |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: {} |
| 5 | + # schedule: |
| 6 | + # - cron: "0 18 * * 2" # Tuesdays at 10 am PST, 11 am PDT |
| 7 | + |
| 8 | +jobs: |
| 9 | + determine_release: |
| 10 | + name: "Determine if release is needed" |
| 11 | + runs-on: ubuntu-latest |
| 12 | + outputs: |
| 13 | + pending_version_number: ${{ steps.versiondetails.outputs.pendingversion }} |
| 14 | + pending_version_available: ${{ steps.versiondetails.outputs.pendingversionavailable }} |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + with: |
| 18 | + fetch-depth: 0 |
| 19 | + - name: Setup Node |
| 20 | + uses: actions/setup-node@v4 |
| 21 | + with: |
| 22 | + node-version: 20 |
| 23 | + - name: Install commit-and-tag-version |
| 24 | + run: | |
| 25 | + npm install -g commit-and-tag-version@^12.5.0 |
| 26 | +
|
| 27 | + - name: Configure git |
| 28 | + run: | |
| 29 | + git config user.name "github-actions[bot]" |
| 30 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 31 | +
|
| 32 | + - name: Check for new commits to release |
| 33 | + run: | |
| 34 | + CURRENT_VERSION=$(cat VERSION) |
| 35 | + COMMITS_TO_RELEASE=$(git log --pretty=oneline v$CURRENT_VERSION..HEAD | wc -l) |
| 36 | +
|
| 37 | + echo Current version: v$CURRENT_VERSION |
| 38 | + echo Commits to release: $COMMITS_TO_RELEASE |
| 39 | +
|
| 40 | + echo "CURRENT_VERSION=${CURRENT_VERSION}" >> $GITHUB_ENV |
| 41 | + echo "COMMITS_TO_RELEASE=${COMMITS_TO_RELEASE}" >> $GITHUB_ENV |
| 42 | +
|
| 43 | + - name: Check if no release needed |
| 44 | + if: ${{ env.COMMITS_TO_RELEASE == 0 }} |
| 45 | + run: | |
| 46 | + echo No changes to release! |
| 47 | + echo Current release: $CURRENT_VERSION |
| 48 | +
|
| 49 | + - name: Determine new version number |
| 50 | + if: ${{ env.COMMITS_TO_RELEASE != 0 }} |
| 51 | + run: | |
| 52 | + commit-and-tag-version |
| 53 | +
|
| 54 | + NEW_VERSION=$(cat VERSION) |
| 55 | + RELEASE_COMMIT_ID=$(git rev-parse HEAD) |
| 56 | +
|
| 57 | + echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_ENV |
| 58 | + echo "RELEASE_COMMIT_ID=${RELEASE_COMMIT_ID}" >> $GITHUB_ENV |
| 59 | +
|
| 60 | + - name: Check if version was bumped |
| 61 | + if: ${{ env.COMMITS_TO_RELEASE != 0 && env.NEW_VERSION == env.CURRENT_VERSION }} |
| 62 | + run: | |
| 63 | + echo No changes to release! |
| 64 | + echo Current release: $CURRENT_VERSION |
| 65 | +
|
| 66 | + - name: "Show pending version details" |
| 67 | + if: ${{ env.COMMITS_TO_RELEASE != 0 && env.NEW_VERSION != env.CURRENT_VERSION }} |
| 68 | + id: versiondetails |
| 69 | + shell: bash |
| 70 | + run: | |
| 71 | + echo New version: v$NEW_VERSION |
| 72 | + echo Commit ID: $RELEASE_COMMIT_ID |
| 73 | + echo Previous version: v$CURRENT_VERSION |
| 74 | + echo Changes to be released: |
| 75 | + git log --pretty=oneline v$CURRENT_VERSION..v$NEW_VERSION |
| 76 | +
|
| 77 | + git show v$NEW_VERSION |
| 78 | +
|
| 79 | + echo "pendingversion=${NEW_VERSION}" >> $GITHUB_OUTPUT |
| 80 | + echo "pendingversionavailable=true" >> $GITHUB_OUTPUT |
| 81 | +
|
| 82 | + run_unit_tests: |
| 83 | + name: "Run unit tests" |
| 84 | + needs: determine_release |
| 85 | + if: needs.determine_release.outputs.pending_version_available == 'true' |
| 86 | + uses: ./.github/workflows/cdk-checks.yml |
| 87 | + |
| 88 | + run_integration_tests: |
| 89 | + name: "Run integration tests" |
| 90 | + needs: determine_release |
| 91 | + if: needs.determine_release.outputs.pending_version_available == 'true' |
| 92 | + permissions: |
| 93 | + id-token: write |
| 94 | + contents: read |
| 95 | + uses: ./.github/workflows/integ-tests.yml |
| 96 | + |
| 97 | + release_new_version: |
| 98 | + name: "Release the new version" |
| 99 | + needs: [determine_release, run_unit_tests, run_integration_tests] |
| 100 | + if: needs.determine_release.outputs.pending_version_available == 'true' |
| 101 | + runs-on: ubuntu-latest |
| 102 | + permissions: |
| 103 | + contents: write |
| 104 | + id-token: write |
| 105 | + steps: |
| 106 | + - uses: actions/checkout@v4 |
| 107 | + with: |
| 108 | + fetch-depth: 0 |
| 109 | + - name: Setup Node |
| 110 | + uses: actions/setup-node@v4 |
| 111 | + with: |
| 112 | + node-version: 20 |
| 113 | + - name: Install commit-and-tag-version |
| 114 | + run: | |
| 115 | + npm install -g commit-and-tag-version@^12.5.0 |
| 116 | +
|
| 117 | + - name: Configure git |
| 118 | + run: | |
| 119 | + git config user.name "github-actions[bot]" |
| 120 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
0 commit comments