forked from TA-Lib/ta-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (70 loc) · 2.53 KB
/
release-step-2.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Upgrade a draft release to an official public release.
#
# More info: README-DEVS.md
name: Release (step 2)
# Controls when the workflow will run
on:
workflow_dispatch:
jobs:
create_release:
runs-on: ubuntu-latest
steps:
- name: Checkout main branch
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0 # Fetch all history for all tags
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Prepare shell envs
shell: bash
run: |
VERSION=$(cat VERSION)
echo "VERSION=${VERSION}" >> $GITHUB_ENV
TAG="v${VERSION}"
echo "TAG=${TAG}" >> $GITHUB_ENV
echo "PYTHON=python3" >> $GITHUB_ENV
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Pre-release checks
shell: bash
run: |
$PYTHON $GITHUB_WORKSPACE/scripts/pre-release-checks.py
- name: Upgrade draft release to public release
id: release_vars
uses: actions/github-script@v7
env:
TAG: ${{ env.TAG }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
script: |
const tag_name = process.env.TAG;
console.log(`tag_name: ${tag_name}`);
try {
// Check if the draft release exists
const { data: releases } = await github.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo,
});
const release = releases.find(release => release.tag_name === tag_name);
if (!release) {
core.setFailed(`No draft release found for tag ${tag_name}. Please run "Release (step 1)" first.`);
return;
}
if (!release.draft) {
core.setFailed(`Release for tag ${tag_name} is already officially published.`);
return;
}
// Publish the draft release
await github.rest.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release.id,
draft: false,
});
console.log(`Published release for tag ${tag_name} completed`);
} catch (error) {
core.setFailed(`Error while publishing release: ${error.message}`);
}