Update package.json. #18
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: 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: 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: Test release | ||
- run: | | ||
git config user.name "github-actions[bot]" | ||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
git add . | ||
git commit -m "generated" | ||
git push | ||
- 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 |