Update package.json. #31
This file contains 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: Release | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
#on: | |
# workflow_call: | |
# inputs: | |
# tag: | |
# required: true | |
# type: string | |
jobs: | |
release: | |
runs-on: ubuntu-22.04 | |
name: Nightly Release | |
env: | |
GITHUB_CONTEXT: ${{ toJson(github) }} | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '18.x' | |
- name: Install Dependencies | |
run: npm install | |
- name: Compile | |
run: | | |
npm i -g @vercel/ncc | |
ncc build index.js --license licenses.txt | |
- name: Compose Release Tag | |
id: release_tag | |
run: | | |
if [[ ${{ github.event_name }} == "pull_request" ]]; then | |
SHA=${{ github.event.pull_request.head.sha }} | |
else | |
SHA=$(echo "$GITHUB_CONTEXT" | jq '.event.commits[].id' | tail -2 | head -1 | sed 's/\"//g') | |
fi | |
DATE=$(git show -s --format=%ad --date=format:'%Y-%m-%d' $SHA) | |
TAG=dev-$DATE-${SHA::8} | |
echo "SHA: $SHA" | |
echo "TAG: $TAG" | |
echo "TAG=$TAG" >> $GITHUB_OUTPUT | |
echo "SHA=$SHA" >> $GITHUB_OUTPUT | |
# - name: login | |
# env: | |
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# run: gh auth login --with-token <<< "${{ secrets.GITHUB_TOKEN }}" | |
- name: Commit Dist Files | |
id: commit_dist_files | |
run: | | |
BRANCH="dev-nightly-release" | |
git config user.name 'github-actions[bot]' | |
git config user.email 'github-actions[bot]@users.noreply.github.com' | |
git checkout -B $BRANCH | |
git pull $BRANCH | |
git add dist/* | |
git commit -m "Add compiled js file." | |
git push origin $BRANCH | |
git tag -a -m ${{ steps.release_tag.outputs.TAG }} ${{ steps.release_tag.outputs.TAG }} | |
git push --follow-tags | |
# | |
# - name: Release | |
# id: release | |
# env: | |
# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# run: | | |
# REPO=$(echo "$GITHUB_CONTEXT" | jq -r '.repository') | |
# TAG=${{ steps.release_tag.outputs.TAG }} | |
# SHA=${{ steps.release_tag.outputs.SHA }} | |
# | |
# # git tag -a ${{ steps.release_tag.outputs.TAG }} | |
# # git push --follow-tags | |
# | |
# gh api repos/$REPO/git/refs -f ref="refs/tags/$TAG" -f sha="$SHA" | |
# # gh release create ${{ steps.release_tag.outputs.TAG }} --repo "$REPO" --title "some title" --generate-notes |