Skip to content

Release

Release #35

Workflow file for this run

name: Release
on:
workflow_run:
workflows:
- Tagging
types:
- completed
branches:
- main
workflow_dispatch:
jobs:
release:
runs-on: ubuntu-latest
if: ${{ contains(github.ref, 'main') && github.event_name != 'schedule' }}
steps:
- name: Set Tag Value
run: |
export DATE=v$(echo `date +'%Y.%m'`)
echo "DATE=${DATE}" >> $GITHUB_ENV
echo "TAG=$(echo `git tag -l ${DATE}`)" >> $GITHUB_ENV
- name: Create Release
uses: actions/github-script@v7
with:
github-token: ${{ github.token }}
script: |
const { repo: { owner, repo }, sha } = context;
const tag = process.env.DATE;
let release_id = 0;
try {
const release = await github.rest.repos.createRelease({
owner, repo,
tag_name: tag,
title: tag,
name: tag,
draft: false,
make_latest: "true",
target_commitish: sha
});
release_id = release.data.id;
} catch (e) {
let latest;
if (e.status == 422) { // Release alredy exists
latest = await github.rest.repos.getLatestRelease({
owner, repo
});
}
release_id = latest.data.id;
}
return release_id