OpenData Release #43
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: OpenData Release | |
on: | |
workflow_dispatch: | |
inputs: | |
release_tag: | |
description: 'Release tag: "{n}.{n}.{n}" e.g. 3.0.0, for Pre-Release "{n}.{n}.{n}rc{n}"' | |
required: true | |
pre_release: | |
description: 'Mark GitHub release as pre-release: [true, false]' | |
required: true | |
default: 'false' | |
env: | |
RELEASE_TAG: ${{ inputs.release_tag }} | |
PRE_RELEASE: ${{ inputs.pre_release }} | |
jobs: | |
build: | |
uses: ./.github/workflows/build.yml | |
secrets: inherit | |
release: | |
runs-on: ubuntu-latest | |
needs: build | |
outputs: | |
heading: ${{ steps.slack_vars.outputs.heading }} | |
title: ${{ steps.slack_vars.outputs.title }} | |
build_branch: ${{ steps.slack_vars.outputs.branch }} | |
run_url: ${{ steps.slack_vars.outputs.run_url }} | |
run_id: ${{ steps.slack_vars.outputs.run_id }} | |
run_status: ${{ steps.slack_vars.outputs.run_status }} | |
run_date: ${{ steps.slack_vars.outputs.run_date }} | |
steps: | |
# - name: is branch valid for release | |
# if: ${{ !startsWith(github.ref_name , 'release/') }} | |
# run: | | |
# echo "Releases must be trigged on branch named 'release/x.x.x'" | |
# exit 1 | |
- name: Check tag is valid for release | |
if: env.PRE_RELEASE == 'false' | |
run: | | |
VALID=$(echo ${{ env.RELEASE_TAG }} | grep -oPc "^(\d+)\.(\d+)\.(\d+)$") | |
if [[ ! "$VALID" == 1 ]]; then | |
echo "Release Tag ${{ env.RELEASE_TAG }} is not valid" | |
exit 1 | |
fi | |
- name: Check tag is valid for pre-release | |
if: env.PRE_RELEASE == 'true' | |
run: | | |
VALID=$(echo ${{ env.RELEASE_TAG }} | grep -oPc "^(\d+)\.(\d+)\.(\d+)rc(\d+)$") | |
if [[ ! "$VALID" == 1 ]]; then | |
echo "Release Tag ${{ env.RELEASE_TAG }} is not valid" | |
exit 1 | |
fi | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.ref_name }} | |
fetch-depth: 0 | |
- name: Setup github user | |
run: | | |
git config --global user.email ${{ env.GIT_EMAIL }} | |
git config --global user.name ${{ env.GIT_USERNAME }} | |
git config --global pull.ff only | |
env: | |
GIT_EMAIL: ${{ secrets.BUILD_GIT_EMAIL }} | |
GIT_USERNAME: ${{ secrets.BUILD_GIT_USERNAME }} | |
- name: Tag Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.BUILD_GIT_TOKEN }} | |
run: | | |
git checkout ${{ github.ref_name }} | |
git tag ${{ env.RELEASE_TAG }} | |
- name: Download JSON spec | |
uses: actions/download-artifact@v3 | |
with: | |
name: extracted_spec | |
path: ${{ github.workspace }}/ | |
# --- Create Release --- # | |
- name: Push changes | |
run: | | |
git push origin ${{ env.RELEASE_TAG }} | |
git push | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.BUILD_GIT_TOKEN }} | |
with: | |
tag_name: ${{ env.RELEASE_TAG }} | |
release_name: Release ${{ env.RELEASE_TAG }} | |
body_path: "" | |
draft: false | |
prerelease: ${{ env.PRE_RELEASE }} | |
# --- Attach build assest --- # | |
- name: Upload JSON Spec | |
id: upload-source-release-asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.BUILD_GIT_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ${{ github.workspace }}/${{ needs.build.outputs.spec_filename }} | |
asset_name: ${{ needs.build.outputs.spec_filename }} | |
asset_content_type: application/octet-stream | |
# --- Slack notify --- # | |
- name: slack message vars | |
id: slack_vars | |
run: | | |
HEAD=$(echo "*${{ github.event.repository.name}} Release* (${{ env.RELEASE_TAG }})") | |
DATE=$(date) | |
TITLE=$(echo "• <https://github.com/${{ github.repository }}/releases/tag/${{ env.RELEASE_TAG }}|${{ github.event.repository.name }} ${{ env.RELEASE_TAG }} - Release Notes>") | |
JOB_URL=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
echo "heading=$HEAD" >> $GITHUB_OUTPUT | |
echo "run_date=$DATE" >> $GITHUB_OUTPUT | |
echo "title=$TITLE" >> $GITHUB_OUTPUT | |
echo "run_url=$JOB_URL" >> $GITHUB_OUTPUT | |
echo "run_id=${{ github.run_id }}" >> $GITHUB_OUTPUT | |
echo "branch=${{ github.ref_name }}" >> $GITHUB_OUTPUT | |
echo "run_status=${{ job.status }}" >> $GITHUB_OUTPUT | |
slack: | |
uses: OasisLMF/OasisLMF/.github/workflows/notify.yml@main | |
secrets: inherit | |
needs: release | |
with: | |
heading: ${{ needs.release.outputs.heading }} | |
title: ${{ needs.release.outputs.title }} | |
build_branch: ${{ needs.release.outputs.build_branch }} | |
run_url: ${{ needs.release.outputs.run_url }} | |
run_id: ${{ needs.release.outputs.run_id }} | |
run_status: ${{ needs.release.outputs.run_status }} | |
run_date: ${{ needs.release.outputs.run_date }} |