Skip to content

release

release #2

Workflow file for this run

name: release
on:
workflow_dispatch:
inputs:
pre_release:
required: true
description: Create pre-release version, eq. 1.0.0-rc.0
type: boolean
default: false
push:
branches:
- release
jobs:
release_tag:
name: conventional changelog
runs-on: ubuntu-22.04
outputs:
changelog: ${{steps.changelog.outputs.clean_changelog}}
tag: ${{steps.changelog.outputs.tag}}
skipped: ${{steps.changelog.outputs.skipped}}
steps:
- name: checkout all history
# https://github.com/actions/checkout
uses: actions/checkout@v4
with:
# checkout whole history
fetch-depth: 0
- name: calculate new version and create changelog content
id: changelog
# https://github.com/TriPSs/conventional-changelog-action
uses: TriPSs/conventional-changelog-action@v5
with:
# you can also create separate token to trace action
github-token: "${{secrets.GITHUB_TOKEN}}"
# do not create changelog file, the content is used at next step for relase body
output-file: false
# do not create additional commit, just tag current commit with the version
skip-commit: true
# do not pull - we already checked out the selection we want to use for versioning in previous step
skip-git-pull: true
# skip tag push - it will not push but it will tag
git-push: false
# set to true to flag rc, eg 0.1.0-rc.0
pre-release: ${{inputs.pre_release}}
# initial version if no tag present
fallback-version: 0.0.1
log_release_tag:
needs: release_tag
name: log version output
runs-on: ubuntu-22.04
steps:
- name: info
run: |
echo skipped=${{needs.release_tag.outputs.skipped}}
echo tag=${{needs.release_tag.outputs.tag}}
frontend:
# it needs to be checked on string value
if: needs.release_tag.outputs.skipped == 'false'
needs: release_tag
name: frontend
uses: ./.github/workflows/_ghcr.yml
with:
ghcr_user: ${{github.actor}}
base_image_name: ghcr.io/research-software-directory/kin-rpd/frontend
image_tag: ${{needs.release_tag.outputs.tag}}
dockerfile: frontend/Dockerfile
docker_context: ./frontend
secrets:
token: ${{secrets.GITHUB_TOKEN}}
nginx:
# it needs to be checked on string value
if: needs.release_tag.outputs.skipped == 'false'
needs: release_tag
name: nginx
uses: ./.github/workflows/_ghcr.yml
with:
ghcr_user: ${{github.actor}}
base_image_name: ghcr.io/research-software-directory/kin-rpd/nginx
image_tag: ${{needs.release_tag.outputs.tag}}
dockerfile: nginx/Dockerfile
docker_context: ./nginx
secrets:
token: ${{secrets.GITHUB_TOKEN}}
documentation:
# it needs to be checked on string value
if: needs.release_tag.outputs.skipped == 'false'
needs: release_tag
name: documentation
uses: ./.github/workflows/_ghcr.yml
with:
ghcr_user: ${{github.actor}}
base_image_name: ghcr.io/research-software-directory/kin-rpd/documentation
image_tag: ${{needs.release_tag.outputs.tag}}
dockerfile: documentation/Dockerfile
docker_context: ./documentation
secrets:
token: ${{secrets.GITHUB_TOKEN}}
deployment_files:
# it needs to be checked on string value
if: needs.release_tag.outputs.skipped == 'false'
needs: [release_tag,frontend,nginx,documentation]
name: create deployment.zip
runs-on: ubuntu-22.04
steps:
- name: checkout branch
# https://github.com/actions/checkout
uses: actions/checkout@v4
- name: update docker-compose.yml
run: |
echo replace :latest tag with ${{needs.release_tag.outputs.tag}}
sed -i -e 's/:latest/:${{needs.release_tag.outputs.tag}}/g' ./deployment/docker-compose.yml
cat ./deployment/docker-compose.yml
# - name: update CITATION.cff
# # use doublequotes in second replace "" to enable variable substitution with bash
# run: |
# echo replace version line
# sed -i -e 's/^version:.*/version: ${{needs.release_tag.outputs.tag}}/' CITATION.cff
# echo replace date
# sed -i -e "s/^date-released:.*/date-released: '$(date +%F)'/" CITATION.cff
# cat CITATION.cff
- name: zip deployment files
run: |
zip --junk-paths deployment.zip \
./deployment/docker-compose.yml \
./nginx/nginx.conf \
.env.example \
./deployment/README.md
- name: Upload deployment.zip
# https://github.com/actions/upload-artifact
uses: actions/upload-artifact@v4
with:
name: deployment
path: deployment.zip
# - name: Upload CITATION.cff
# # https://github.com/actions/upload-artifact
# uses: actions/upload-artifact@v4
# with:
# name: citation
# path: CITATION.cff
release_draft:
# it needs to be checked on string value
if: needs.release_tag.outputs.skipped == 'false'
needs: [ release_tag, deployment_files ]
name: create release draft
runs-on: ubuntu-22.04
steps:
- name: get deployment.zip
uses: actions/download-artifact@v4
with:
name: deployment
- name: validate info
run: |
echo show files
ls -lha
echo tag_name=${{needs.release_tag.outputs.tag}}
- name: create release draft
# https://github.com/softprops/action-gh-release
uses: softprops/action-gh-release@v2
env:
# The token is provided by Actions, you do not need to create your own token
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
tag_name: ${{needs.release_tag.outputs.tag}}
name: ${{needs.release_tag.outputs.tag}}
body: ${{needs.release_tag.outputs.changelog}}
draft: true
prerelease: ${{inputs.pre_release}}
files: deployment.zip
# citation:
# # it needs to be checked on string value
# if: needs.release_tag.outputs.skipped == 'false'
# needs: [ release_tag, deployment_files, release_draft ]
# name: citations
# uses: ./.github/workflows/_cff.yml
# with:
# artifact: citation
# branch: main
# commit_message: "chore(release): update citation file"
# secrets:
# # need to pass PAT using secrets prop to reusable workflow (module)
# # the secrets are not passed automatically to child modules
# # see https://docs.github.com/en/enterprise-cloud@latest/actions/using-workflows/reusing-workflows#passing-inputs-and-secrets-to-a-reusable-workflow
# token: ${{ secrets.PAT_RELEASE }}