This repository has been archived by the owner on Nov 29, 2023. It is now read-only.
Create Release #231
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: Create Release | |
on: | |
schedule: | |
- cron: '0 14 * * 1-5' | |
jobs: | |
release_needed: | |
name: Check for Diff Between Main and the Latest Release | |
runs-on: ubuntu-latest | |
outputs: | |
release_needed: ${{ steps.release_needed.outputs.release_needed }} | |
steps: | |
- name: Determine if New Release is Needed | |
id: release_needed | |
run: | | |
REL_TIME=$(curl -Ls -H "Accept: application/vnd.github+json" -H "Authorization: token $TOKEN" $GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases/latest | jq -r '.published_at') # Get latest release time | |
COMMITS=$(curl -Ls -H "Accept: application/vnd.github+json" -H "Authorization: token $TOKEN" $GITHUB_API_URL/repos/$GITHUB_REPOSITORY/commits?since=$REL_TIME | jq '. | length') # Get all commits since last release | |
if [ $COMMITS '>' 0 ]; then echo "release_needed=true" >> $GITHUB_OUTPUT; else :; fi # If there have been commits to main since the last release, make a new release | |
env: | |
TOKEN: ${{ secrets.DX_GITHUB_TOKEN }} | |
create_release: | |
name: Create A New Release | |
runs-on: ubuntu-latest | |
needs: release_needed | |
if: ${{needs.release_needed.outputs.release_needed}} | |
steps: | |
- name: Make Release | |
run: | | |
TAG=$(date +"v%Y.%m.%d") # Format release name/tag using current date | |
curl -Lfs -X POST -H "Accept: application/vnd.github+json" -H "Authorization: token $TOKEN" $GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases -d '{"tag_name":"'"$TAG"'","name":"'"$TAG"'","generate_release_notes":true}' # Create release | |
env: | |
TOKEN: ${{ secrets.DX_GITHUB_TOKEN }} |