Skip to content

Commit

Permalink
GHA: removed npm logging. Generate release version. Use npm publish i…
Browse files Browse the repository at this point in the history
…nstead of semantic-release. Add git tag (untested)
  • Loading branch information
skripted-io committed Sep 29, 2023
1 parent 1624166 commit 7ee6ee9
Showing 1 changed file with 30 additions and 15 deletions.
45 changes: 30 additions & 15 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
with:
cache: "npm"
node-version-file: ".nvmrc"

- name: Info
run: |
cat <<EOF
Expand All @@ -34,23 +35,37 @@ jobs:
GitHub ref: ${{ github.ref }}
GitHub head ref: ${{ github.head_ref }}
EOF
- name: Setup
- name: Setup & Test
run: |
npm ci
mkdir -p ./test/results
- run: npm test
- run: npm run build
# - name: Deploy to GH Pages
# uses: peaceiris/actions-gh-pages@v3
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# publish_dir: playground
# full_commit_message: "Build for ${{ github.sha }} ${{ github.event.head_commit.message }}"
- name: semantic-release
npm test
- name: Build
run: npm run build

- name: Generate release version
run: |
export RELEASE_TIMESTAMP=$(date +'%Y%m%d%H%M%S')
export VPKG=$($(npm bin)/json -f package.json version)
export VERSION=${VPKG}-prerelease.${RELEASE_TIMESTAMP}
echo "RELEASE_VERSION=${VERSION}" >> $GITHUB_ENV
echo "NPM_TAG=latest" >> $GITHUB_ENV
- name: Deploy to NPM
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx --no -- semantic-release
- name: Print npm log
if: failure() # Only run this step if a previous step has failed
run: cat /home/runner/.npm/_logs/*.log || echo "No log files exist"
NPM_TAG: ${{ env.NPM_TAG }}
run: |
echo "Deploying version $RELEASE_VERSION to $NPM_TAG"
npm set //registry.npmjs.org/:_authToken=$NPM_TOKEN
npm publish --tag $NPM_TAG --dry-run
- name: Check Release Version and Create Tag
run: |
if npm info | grep -q $RELEASE_VERSION; then
git tag $RELEASE_VERSION
git push origin $RELEASE_VERSION
fi

0 comments on commit 7ee6ee9

Please sign in to comment.