Skip to content

Commit 8a8dfb8

Browse files
committed
use github actions to publish to github and to npm, and then call codepipeline
1 parent 9215459 commit 8a8dfb8

File tree

1 file changed

+41
-21
lines changed

1 file changed

+41
-21
lines changed

.github/workflows/publish-npm.yml

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish to npm
1+
name: Publish packages
22

33
on:
44
workflow_dispatch:
@@ -24,51 +24,71 @@ jobs:
2424
registry-url: 'https://registry.npmjs.org'
2525
scope: '@aws-toolkits'
2626

27-
- name: Debug info and skip validation for testing
27+
- name: Validate release commits
2828
run: |
2929
VERSION=$(cat version)
30-
echo "Current version: $VERSION"
31-
echo "Git log authors (last 5 commits):"
32-
git log --pretty=format:"%an - %s" -5
33-
echo ""
34-
echo "Skipping validation check for manual testing"
35-
echo "SHOULD_RELEASE=true (forced for testing)"
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
3657
3758
- name: Increment version and commit
3859
run: |
3960
git config --global user.name "aws-toolkit-automation"
4061
git config --global user.email "<>"
4162
42-
echo "Before version increment:"
43-
cat version
44-
4563
# increase the version
4664
cat version | (IFS="." ; read a b c && echo $a.$b.$((c + 1)) > version)
4765
VERSION=$(cat version)
48-
echo "After version increment: $VERSION"
66+
echo "version is now: $VERSION"
4967
5068
git add version
5169
git commit -m "Release version $VERSION"
52-
echo "Pushing to test-release branch"
5370
git push origin test-release
5471
5572
- name: Build npm package
5673
run: |
5774
VERSION=$(cat version)
58-
echo "Building package with version: $VERSION"
5975
cd telemetry/vscode
60-
echo "Installing dependencies..."
6176
npm ci
62-
echo "Setting npm package version..."
6377
npm version "$VERSION"
64-
echo "Creating package..."
6578
npm pack
66-
echo "Package files created:"
67-
ls -la *.tgz
6879
6980
- name: Publish to npm
7081
run: |
7182
cd telemetry/vscode
72-
echo "Publishing package to npm..."
7383
npm publish $(ls -1 *.tgz) --access public
74-
echo "Package published successfully!"
84+
85+
# - name: Configure AWS credentials
86+
# uses: aws-actions/configure-aws-credentials@v4
87+
# with:
88+
# role-to-assume: arn:aws:iam::149820434093: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

Comments
 (0)