Skip to content

Publish Release

Publish Release #71

Workflow file for this run

name: Publish Release
permissions: write-all
on:
workflow_dispatch:
inputs:
milestone:
description: 'The milestone to generate a release for (ex: 6.5.1)'
required: true
type: string
env:
# Needed for GitHub CLI
GH_TOKEN: ${{ github.token }}
defaults:
run:
shell: pwsh
jobs:
build_release_notes:
runs-on: ubuntu-latest
name: Generate Release Notes
steps:
- name: Get Contributors
id: get-contribs
uses: Keboo/GitHubHelper@master
with:
milestone: '${{ inputs.milestone }}'
repository: 'ikabot'
repository-owner: 'Ikabot-Collective'
token: ${{ github.token }}
- name: Generate Release Notes
run: |
$response = gh api --method POST -H "Accept: application/vnd.github+json" /repos/${{ github.repository }}/releases/generate-notes -f tag_name='v${{ inputs.milestone }}'
$json = $response | ConvertFrom-Json
$releaseNotes = $json.body
$contributors = "${{ steps.get-contribs.outputs.contributors }}"
$releaseNotes | Out-File -Append "ReleaseNotes.md"
"`n" | Out-File -Append "ReleaseNotes.md"
$contributors | Out-File -Append "ReleaseNotes.md"
cat "ReleaseNotes.md"
- name: Upload Release Notes
uses: actions/upload-artifact@v3
with:
name: ReleaseNotes
path: "ReleaseNotes.md"
update_version_number:
runs-on: ubuntu-latest
name: Update Version Number
steps:
- uses: actions/checkout@v3
- name: Replace version value
run: sed -i 's/IKABOT_VERSION = ".\+"/IKABOT_VERSION = "${{ inputs.milestone }}"/' ikabot/config.py
- name: Push changes
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add ikabot/config.py
git commit -m "Bump Ikabot version ${{ inputs.milestone }}"
git push
build_artifacts:
needs: [update_version_number]
name: Build artifacts
uses: ./.github/workflows/build_artifacts.yml
create_release:
needs: [build_artifacts, build_release_notes]
runs-on: ubuntu-latest
name: Create Draft Release
steps:
- name: Download Pre-Compiled Ikabot Artifacts
uses: actions/download-artifact@v3
with:
name: PreCompiledIkabot
path: pre-compiled-ikabot
- name: Zip Ikabot
run: |
cd pre-compiled-ikabot
zip -r ../Ikabot.zip ikabot/*
cd ..
- name: Download Release Notes
uses: actions/download-artifact@v3
with:
name: ReleaseNotes
- name: Create Release
run: |
# We can't use glob pattern because of this bug https://github.com/cli/cli/issues/5099
gh release create v${{ inputs.milestone }} --repo '${{ github.repository }}' --draft --latest --title "${{ inputs.milestone }}" --notes-file ReleaseNotes.md '${{ github.workspace }}/Ikabot.zip'
publish_release:
needs: [create_release]
runs-on: ubuntu-latest
name: Publish Release
steps:
- name: Publish Release
run: |
gh release edit v${{ inputs.milestone }} --repo '${{ github.repository }}' --draft=false
close_milestone:
needs: [publish_release]
runs-on: ubuntu-latest
name: Close Milestone
steps:
# Doing a checkout, until this issue is resolved.
# https://github.com/valeriobelli/gh-milestone/issues/15
- uses: actions/checkout@v3
- name: Close Milestone
run: |
gh extension install valeriobelli/gh-milestone
$milestones = $(gh milestone list --json number,title) | ConvertFrom-Json
$milestoneNumber = ($milestones | Where-Object { $_.title -eq "${{ inputs.milestone }}" }).number
gh milestone edit $milestoneNumber --state closed
publish_docker:
needs: [publish_release]
name: Publish Docker Image
uses: ./.github/workflows/publish_docker.yml
with:
tag_name: 'v${{ inputs.milestone }}'
permissions:
contents: read
packages: write
publish_pypi:
needs: [publish_release]
name: Publish Python Package
uses: ./.github/workflows/publish_pypi.yml
secrets:
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}