|
| 1 | +name: Releases |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + tags: |
| 8 | + - 'v*.*.*' |
| 9 | + |
| 10 | +jobs: |
| 11 | + release: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + needs: build_artifacts # previous jobs that create artifacts |
| 14 | + steps: |
| 15 | + - name: Checkout |
| 16 | + uses: actions/checkout@v3 |
| 17 | + |
| 18 | + - name: Set up Python |
| 19 | + uses: actions/setup-python@v4 |
| 20 | + with: |
| 21 | + python-version: "3.x" |
| 22 | + |
| 23 | + - name: Determine release info |
| 24 | + id: release_info |
| 25 | + run: | |
| 26 | + if [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then |
| 27 | + TAG="latest" |
| 28 | + RELEASE_NAME="Latest Release" |
| 29 | + LATEST_FLAG="--latest" |
| 30 | + else |
| 31 | + TAG="${GITHUB_REF#refs/tags/}" |
| 32 | + RELEASE_NAME="Release $TAG" |
| 33 | + LATEST_FLAG="" |
| 34 | + fi |
| 35 | + echo "tag=$TAG" >> $GITHUB_OUTPUT |
| 36 | + echo "release_name=$RELEASE_NAME" >> $GITHUB_OUTPUT |
| 37 | + echo "latest_flag=$LATEST_FLAG" >> $GITHUB_OUTPUT |
| 38 | +
|
| 39 | + - name: Update latest tag |
| 40 | + if: github.ref == 'refs/heads/main' |
| 41 | + uses: EndBug/latest-tag@v9 |
| 42 | + with: |
| 43 | + tag-name: latest |
| 44 | + env: |
| 45 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 46 | + |
| 47 | + - name: Generate release notes |
| 48 | + id: notes |
| 49 | + run: | |
| 50 | + notes=$(python create_release_notes.py ${{ steps.release_info.outputs.latest_flag }}) |
| 51 | + echo "release_notes<<EOF" >> $GITHUB_OUTPUT |
| 52 | + echo "$notes" >> $GITHUB_OUTPUT |
| 53 | + echo "EOF" >> $GITHUB_OUTPUT |
| 54 | +
|
| 55 | + - name: Create/update latest release |
| 56 | + if: github.ref == 'refs/heads/main' |
| 57 | + uses: softprops/action-gh-release@v1 |
| 58 | + with: |
| 59 | + tag_name: ${{ steps.release_info.outputs.tag }} |
| 60 | + name: ${{ steps.release_info.outputs.release_name }} |
| 61 | + body: ${{ steps.notes.outputs.release_notes }} |
| 62 | + draft: true |
| 63 | + env: |
| 64 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments