v0.2.15 #12
Workflow file for this run
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 Build - Javelin Python | |
on: | |
release: | |
types: | |
- published | |
env: | |
env_var: ${{ vars.ENV_CONTEXT_VAR }} | |
DEVOPS_REPO: "javelin-cloud" | |
CHANGELOG_BR: main | |
PY_VER: 3.11.8 | |
jobs: | |
javelin-prebuild: | |
permissions: | |
contents: 'read' | |
id-token: 'write' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Setting up Repo Env | |
id: repo_env_setup | |
shell: bash | |
run: |- | |
echo "repository=$(basename ${{ github.repository }})" >> ${GITHUB_OUTPUT} | |
echo "shortsha=$(git rev-parse --short=7 HEAD)" >> ${GITHUB_OUTPUT} | |
- name: Set Lowercase Repo Name | |
id: lc_repository | |
env: | |
REPO_NAME: ${{ steps.repo_env_setup.outputs.repository }} | |
shell: bash | |
run: echo "name=${REPO_NAME,,}" >> ${GITHUB_OUTPUT} | |
- name: DevOps Repository Checkout | |
uses: actions/checkout@v4 | |
with: | |
repository: "${{ github.repository_owner }}/${{ env.DEVOPS_REPO }}" | |
token: ${{ secrets.DEVOPS_GITHUB_TOKEN }} | |
fetch-depth: 0 | |
persist-credentials: false | |
ref: main | |
path: ${{ env.DEVOPS_REPO }} | |
- name: Get Build Config | |
id: build_config | |
shell: bash | |
run: |- | |
chglog_pr_reviewers=$(cat ${{ env.DEVOPS_REPO }}/app-config/javelin-default/release-config.json | jq -r '.changelog.pr_reviewers') | |
echo "chglog_pr_reviewers=${chglog_pr_reviewers}" >> ${GITHUB_OUTPUT} | |
outputs: | |
short_sha: ${{ steps.repo_env_setup.outputs.shortsha }} | |
lc_repository: ${{ steps.lc_repository.outputs.name }} | |
chglog_pr_reviewers: ${{ steps.build_config.outputs.chglog_pr_reviewers }} | |
javelin-validate: | |
permissions: | |
contents: 'read' | |
id-token: 'write' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Validate Release | |
env: | |
RELEASE_NAME: ${{ github.event.release.name }} | |
REGEX_PATTERN: "^v[0-9]+\\.[0-9]+\\.[0-9]+$" | |
shell: bash | |
run: |- | |
if [[ "${{ env.RELEASE_NAME }}" =~ ${{ env.REGEX_PATTERN }} ]]; then | |
echo "Valid version format: ${{ env.RELEASE_NAME }}" | |
else | |
echo "Invalid version format: ${{ env.RELEASE_NAME }}" | |
exit 1 | |
fi | |
javelin-package: | |
needs: | |
- javelin-validate | |
permissions: | |
contents: 'read' | |
id-token: 'write' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Setting up the Package Version | |
env: | |
PY_VER_FILE: "pyproject.toml" | |
RELEASE_NAME: ${{ github.event.release.name }} | |
shell: bash | |
run: |- | |
export RELEASE_VERSION=$(echo ${{ env.RELEASE_NAME }} | sed 's|^v||g') | |
if cat ${{ env.PY_VER_FILE }} | grep 'version = "RELEASE_VERSION"' ; then | |
sed -i "s|^version = \"RELEASE_VERSION\"|version = \"${RELEASE_VERSION}\"|g" ${{ env.PY_VER_FILE }} | |
cat ${file} | |
else | |
echo "Version entry format is wrong in the ${{ env.PY_VER_FILE }} file...!" | |
cat ${file} | |
exit 1 | |
fi | |
- name: Set up Python Version | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.PY_VER }} | |
cache: 'pip' | |
- name: Install Dependencies | |
shell: bash | |
run: |- | |
pip install build | |
- name: Build Package | |
shell: bash | |
run: |- | |
python -m build | |
- name: Publish Package | |
uses: pypa/[email protected] | |
# with: | |
# user: __token__ | |
# password: ${{ secrets.PYPI_API_TOKEN }} | |
javelin-chglog: | |
needs: | |
- javelin-prebuild | |
- javelin-package | |
permissions: | |
contents: 'read' | |
id-token: 'write' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.DEVOPS_GITHUB_TOKEN }} | |
persist-credentials: true | |
- name: Check chglog config | |
id: chglog_config | |
shell: bash | |
run: | | |
if test -d ".chglog" ; then | |
if test -f ".chglog/config.yml" ; then | |
echo "present=true" >> ${GITHUB_OUTPUT} | |
fi | |
fi | |
- name: Install git-chglog and generate CHANGELOG | |
if: ${{ steps.chglog_config.outputs.present == 'true' }} | |
shell: bash | |
run: | | |
curl -sLfO https://github.com/git-chglog/git-chglog/releases/download/v0.15.4/git-chglog_0.15.4_linux_amd64.tar.gz | |
tar -zxvf git-chglog_0.15.4_linux_amd64.tar.gz | |
chmod +x git-chglog | |
./git-chglog --config .chglog/config.yml --output CHANGELOG.md | |
- name: Create Pull Request | |
if: ${{ steps.chglog_config.outputs.present == 'true' }} | |
id: create_pr | |
uses: peter-evans/create-pull-request@v7 | |
with: | |
token: ${{ secrets.DEVOPS_GITHUB_TOKEN }} | |
commit-message: 'devops: Update CHANGELOG for ${{ github.event.release.tag_name }}' | |
title: 'CHANGELOG for ${{ github.event.release.tag_name }}' | |
committer: GitHub Action <[email protected]> | |
author: GitHub Action <[email protected]> | |
body: > | |
This PR is auto-generated by | |
[release pipeline](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) | |
base: ${{ env.CHANGELOG_BR }} | |
branch: cicd-changelog | |
delete-branch: true | |
add-paths: CHANGELOG.md | |
reviewers: ${{ needs.javelin-prebuild.outputs.chglog_pr_reviewers }} | |
outputs: | |
pr_url: ${{ steps.create_pr.outputs.pull-request-url }} | |
pr_num: ${{ steps.create_pr.outputs.pull-request-number }} | |
javelin-package-notify: | |
needs: | |
- javelin-prebuild | |
- javelin-package | |
- javelin-chglog | |
permissions: | |
contents: 'read' | |
id-token: 'write' | |
runs-on: ubuntu-latest | |
if: always() | |
env: | |
CHGLOG_PR_URL: ${{ needs.javelin-chglog.outputs.pr_url }} | |
CHGLOG_PR_NUM: ${{ needs.javelin-chglog.outputs.pr_num }} | |
SVC_NAME: ${{ needs.javelin-prebuild.outputs.lc_repository }} | |
JOB_STATUS: ${{ needs.javelin-package.result }} | |
JOB_STATUS_FAIL_MARK: ":x:" | |
JOB_STATUS_SUCCESS_MARK: ":white_check_mark:" | |
TAG_NAME: ${{ github.event.release.tag_name }} | |
RELEASE_NAME: ${{ github.event.release.name }} | |
RELEASE_AUTHOR: ${{ github.event.release.author.login }} | |
PR_REVIEWERS: ${{ needs.javelin-prebuild.outputs.chglog_pr_reviewers }} | |
BUILD_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
SLACK_PAYLOAD_JSON: slack-package-payload.json | |
steps: | |
- name: DevOps Repository Checkout | |
uses: actions/checkout@v4 | |
with: | |
repository: "${{ github.repository_owner }}/${{ env.DEVOPS_REPO }}" | |
token: ${{ secrets.DEVOPS_GITHUB_TOKEN }} | |
fetch-depth: 0 | |
persist-credentials: true | |
ref: main | |
path: ${{ env.DEVOPS_REPO }} | |
- name: Slack Payload Template | |
shell: bash | |
run: |- | |
if [[ ${{ needs.javelin-package.result }} == "success" ]] ; then | |
export JOB_STATUS_MARK=${JOB_STATUS_SUCCESS_MARK} | |
else | |
export JOB_STATUS_MARK=${JOB_STATUS_FAIL_MARK} | |
fi | |
envsubst < ${{ env.DEVOPS_REPO }}/slack-notify/${{ env.SLACK_PAYLOAD_JSON }} > ${{ env.SLACK_PAYLOAD_JSON }} | |
cat ${{ env.SLACK_PAYLOAD_JSON }} | |
- name: Slack Notification | |
uses: slackapi/[email protected] | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} | |
with: | |
channel-id: "${{ vars.SLACK_CHANNEL_ID }}" | |
payload-file-path: "${{ env.SLACK_PAYLOAD_JSON }}" |