|
| 1 | +name: Publish packages |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + branches: [main] |
| 7 | + |
| 8 | +permissions: |
| 9 | + id-token: write # Required for OIDC authentication with npm |
| 10 | + contents: write # Required to push version commits |
| 11 | + |
| 12 | +jobs: |
| 13 | + publish: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + with: |
| 18 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 19 | + |
| 20 | + - name: Setup Node.js |
| 21 | + uses: actions/setup-node@v4 |
| 22 | + with: |
| 23 | + node-version: '24.x' |
| 24 | + registry-url: 'https://registry.npmjs.org' |
| 25 | + scope: '@aws-toolkits' |
| 26 | + |
| 27 | + - name: Validate release commits |
| 28 | + run: | |
| 29 | + VERSION=$(cat version) |
| 30 | + echo "validating for package version: $VERSION" |
| 31 | + |
| 32 | + # Now we check if there are any "interesting" commits to create a release version. These are any |
| 33 | + # commits that are neither 1. from dependabot or 2. a release commit. |
| 34 | + AUTHOR_DEPENDABOT="dependabot[bot]" |
| 35 | + AUTHOR_AUTOMATION="aws-toolkit-automation" |
| 36 | + |
| 37 | + SHOULD_RELEASE=false |
| 38 | + for author in $(git log --pretty=%an) |
| 39 | + do |
| 40 | + if [ "$author" = $AUTHOR_DEPENDABOT ]; then |
| 41 | + # Ignore dependabot commits, keep searching. |
| 42 | + continue |
| 43 | + elif [ "$author" != $AUTHOR_AUTOMATION ]; then |
| 44 | + # Found a commit to release since last release. |
| 45 | + SHOULD_RELEASE=true |
| 46 | + echo "found at least one commit to release, author: $author" |
| 47 | + fi |
| 48 | + |
| 49 | + # If the commit wasn't from dependabot, then we have enough information. |
| 50 | + break |
| 51 | + done |
| 52 | + |
| 53 | + if [ $SHOULD_RELEASE != true ]; then |
| 54 | + echo "no commits detected that are not from '$AUTHOR_DEPENDABOT' or '$AUTHOR_AUTOMATION'. skipping release." |
| 55 | + exit 1 |
| 56 | + fi |
| 57 | +
|
| 58 | + - name: Increment version and commit |
| 59 | + run: | |
| 60 | + git config --global user.name "aws-toolkit-automation" |
| 61 | + git config --global user.email "<>" |
| 62 | + |
| 63 | + # increase the version |
| 64 | + cat version | (IFS="." ; read a b c && echo $a.$b.$((c + 1)) > version) |
| 65 | + VERSION=$(cat version) |
| 66 | + echo "version is now: $VERSION" |
| 67 | + |
| 68 | + git add version |
| 69 | + git commit -m "Release version $VERSION" |
| 70 | + git push origin main |
| 71 | +
|
| 72 | + - name: Build npm package |
| 73 | + run: | |
| 74 | + VERSION=$(cat version) |
| 75 | + cd telemetry/vscode |
| 76 | + npm ci |
| 77 | + npm version "$VERSION" |
| 78 | + npm pack |
| 79 | +
|
| 80 | + - name: Publish to npm |
| 81 | + run: | |
| 82 | + cd telemetry/vscode |
| 83 | + npm publish $(ls -1 *.tgz) --access public |
| 84 | +
|
| 85 | + - name: Configure AWS credentials |
| 86 | + uses: aws-actions/configure-aws-credentials@v4 |
| 87 | + with: |
| 88 | + role-to-assume: arn:aws:iam::305657142372:role/GitHubActionsCodePipelineRole |
| 89 | + role-session-name: github-actions-codepipeline |
| 90 | + aws-region: us-west-2 |
| 91 | + |
| 92 | + - name: Trigger CodePipeline for Maven/NuGet |
| 93 | + run: | |
| 94 | + aws codepipeline start-pipeline-execution --name PackagePipeline |
0 commit comments