diff --git a/.github/workflows/release_note.yml b/.github/workflows/release_note.yml new file mode 100644 index 0000000..9de4106 --- /dev/null +++ b/.github/workflows/release_note.yml @@ -0,0 +1,77 @@ +name: Create release tag and release note + +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' + +jobs: + create-release-tag: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Get previous tag + id: pre_tag + run: | + echo "version=$(curl -L -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.API_KEY }}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/${{ github.repository }}/releases/latest \ + | jq .tag_name \ + | sed 's/"//g')" >> $GITHUB_OUTPUT + + - name: Previous tag + run: | + echo "${{ steps.pre_tag.outputs.version }}" + + - name: Generate release tag + id: release_tag + run: echo "version=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT + + - name: Release tag + run: | + echo "${{ steps.release_tag.outputs.version }}" + + - name: Generate release note + id: release_note + run: | + echo "note=$(curl -L \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.API_KEY }}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/${{ github.repository }}/releases/generate-notes \ + -d '{"tag_name":"${{ steps.release_tag.outputs.version }}","target_commitish":"main","previous_tag_name":"${{ steps.pre_tag.outputs.version }}"}' \ + | jq .body \ + | sed 's/"//g')" >> $GITHUB_OUTPUT + + - name: Release note debugging 1 + run: | + echo "Authorization: Bearer ${{ secrets.API_KEY }}" + - name: Release note debugging 2 + run: | + echo "https://api.github.com/repos/${{ github.repository }}/releases/generate-notes" + - name: Release note debugging 3 + run: | + echo '{"tag_name":"${{ steps.release_tag.outputs.version }}","target_commitish":"main","previous_tag_name":"${{ steps.pre_tag.outputs.version }}"}' + - name: Release note debugging 4 + run: | + curl -L \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.API_KEY }}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/${{ github.repository }}/releases/generate-notes \ + -d '{"tag_name":"${{ steps.release_tag.outputs.version }}","target_commitish":"main","previous_tag_name":"${{ steps.pre_tag.outputs.version }}"}' + + - name: Release note + run: | + echo "${{ steps.release_note.outputs.note }}" + + - name: Create Release + run: | + curl -X POST \ + -H "Authorization: token ${{ secrets.API_KEY }}" \ + -d "{ \"tag_name\": \"${{ steps.release_tag.outputs.version }}\", \"name\": \"${{ steps.release_tag.outputs.version }}\", \"body\": \"${{ steps.release_note.outputs.note }}\"}" \ + https://api.github.com/repos/${{ github.repository }}/releases