Release and Publish #38
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 and Publish | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Version number' | |
required: true | |
changes_1: | |
description: 'Change entry' | |
required: true | |
changes_2: | |
description: 'Change entry' | |
required: false | |
changes_3: | |
description: 'Change entry' | |
required: false | |
changes_4: | |
description: 'Change entry' | |
required: false | |
changes_5: | |
description: 'Change entry' | |
required: false | |
changes_6: | |
description: 'Change entry' | |
required: false | |
changes_7: | |
description: 'Change entry' | |
required: false | |
changes_8: | |
description: 'Change entry' | |
required: false | |
jobs: | |
release_build: | |
name: Build the release | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
token: ${{secrets.GITHUB_TOKEN}} | |
- name: Build the changelog text | |
run: | | |
echo 'CHANGES<<EOF' >> $GITHUB_ENV | |
echo "## [${{github.event.inputs.version}}] - $(date +'%Y-%m-%d')" >> $GITHUB_ENV | |
echo "- ${{github.event.inputs.changes_1}}" >> $GITHUB_ENV | |
if [[ -n "${{github.event.inputs.changes_2}}" ]]; then echo "- ${{github.event.inputs.changes_2}}" >> $GITHUB_ENV; fi | |
if [[ -n "${{github.event.inputs.changes_3}}" ]]; then echo "- ${{github.event.inputs.changes_3}}" >> $GITHUB_ENV; fi | |
if [[ -n "${{github.event.inputs.changes_4}}" ]]; then echo "- ${{github.event.inputs.changes_4}}" >> $GITHUB_ENV; fi | |
if [[ -n "${{github.event.inputs.changes_5}}" ]]; then echo "- ${{github.event.inputs.changes_5}}" >> $GITHUB_ENV; fi | |
if [[ -n "${{github.event.inputs.changes_6}}" ]]; then echo "- ${{github.event.inputs.changes_6}}" >> $GITHUB_ENV; fi | |
if [[ -n "${{github.event.inputs.changes_7}}" ]]; then echo "- ${{github.event.inputs.changes_7}}" >> $GITHUB_ENV; fi | |
if [[ -n "${{github.event.inputs.changes_8}}" ]]; then echo "- ${{github.event.inputs.changes_8}}" >> $GITHUB_ENV; fi | |
echo "" >> $GITHUB_ENV | |
echo 'EOF' >> $GITHUB_ENV | |
- name: Update version numbers | |
run: | | |
sed -i -E 's/ version=.+,/ version="'${{github.event.inputs.version}}'",/' setup.py | |
- name: Update the changelog | |
run: | | |
ex CHANGELOG.md <<eof | |
3 insert | |
$CHANGES | |
. | |
xit | |
eof | |
- name: Update the copyright year | |
run: | | |
find . -type f -exec sed -i -E 's/Copyright [0-9\-]+ DMTF/Copyright 2019-'$(date +'%Y')' DMTF/' {} \; | |
find . -type f -exec sed -i -E 's/Copyright \(c\) [0-9\-]+,/Copyright (c) 2019-'$(date +'%Y')',/' {} \; | |
- name: Commit and push the updates | |
run: | | |
git config user.name "GitHub Release Workflow" | |
git config user.email "<>" | |
git add * | |
git commit -s -m "${{github.event.inputs.version}} versioning" | |
git push origin main | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.x' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install setuptools wheel twine | |
- name: Build the distribution | |
run: | | |
python setup.py sdist bdist_wheel bdist_rpm | |
mv dist/*.rpm . | |
- name: Upload to pypi | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.PYPI_API_TOKEN }} | |
- name: Make the release | |
env: | |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
run: | | |
gh release create ${{github.event.inputs.version}} -t ${{github.event.inputs.version}} -n "Changes since last release:"$'\n\n'"$CHANGES" *.rpm | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{secrets.DOCKER_USERNAME}} | |
password: ${{secrets.DOCKER_PASSWORD}} | |
- name: Build Docker image and push | |
id: docker_build | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
tags: dmtf/redfish-tacklebox:${{github.event.inputs.version}},dmtf/redfish-tacklebox:latest | |
platforms: linux/arm64,linux/amd64 | |
- name: Image digest | |
run: echo ${{steps.docker_build.outputs.digest}} |