Skip to content

Commit 06cdf7c

Browse files
authored
Add workflow to push the release (#810)
* Add workflow to push the release * Create tag * Review * Fix sha in tag creation, checkout tag in publish * Typo
1 parent 12e65a2 commit 06cdf7c

File tree

2 files changed

+67
-24
lines changed

2 files changed

+67
-24
lines changed

.github/workflows/publish.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Publish
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
8+
jobs:
9+
upload_release:
10+
name: Upload release
11+
runs-on: ubuntu-20.04
12+
steps:
13+
- uses: actions/checkout@v2
14+
ref: ${{ github.event.release.tag_name }}
15+
# Include all history and tags, needed for building the right version
16+
with:
17+
fetch-depth: 0
18+
19+
- uses: actions/setup-python@v2
20+
name: Install Python
21+
with:
22+
python-version: "3.10"
23+
24+
- name: Install datadog_checks_dev
25+
run: |
26+
python -m pip install datadog_checks_dev[cli]
27+
28+
- name: Set ddev pypi credentials
29+
run: |
30+
ddev config set pypi.user __token__
31+
ddev config set pypi.pass ${{ secrets.PYPI_TOKEN }}
32+
33+
- name: Publish the wheel to PyPI
34+
run: |
35+
ddev release upload .

.github/workflows/release.yml

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,42 @@
11
name: Release
22

33
on:
4-
release:
5-
types:
6-
- published
4+
pull_request:
5+
types: [closed]
6+
branches:
7+
- master
78

89
jobs:
9-
upload_release:
10-
name: Upload release
11-
runs-on: ubuntu-20.04
10+
create_release:
11+
name: Create release
12+
runs-on: ubuntu-latest
13+
if: github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/')
1214
steps:
13-
- uses: actions/checkout@v2
14-
# Include all history and tags, needed for building the right version
15+
- name: Get GitHub App token
16+
id: get_token
17+
uses: tibdex/github-app-token@v1
1518
with:
16-
fetch-depth: 0
17-
18-
- uses: actions/setup-python@v2
19-
name: Install Python
19+
app_id: ${{ secrets.PIPELINE_GITHUB_APP_ID }}
20+
private_key: ${{ secrets.PIPELINE_GITHUB_APP_PRIVATE_KEY }}
21+
- name: Create release
22+
uses: actions/github-script@v5
23+
env:
24+
RELEASE_BRANCH: ${{ github.head_ref }}
2025
with:
21-
python-version: "3.10"
22-
23-
- name: Install datadog_checks_dev
24-
run: |
25-
python -m pip install datadog_checks_dev[cli]
26+
github-token: ${{ steps.get_token.outputs.token }}
27+
script: |
28+
const tagName = process.env.RELEASE_BRANCH.split("/")[1];
2629
27-
- name: Set ddev pypi credentials
28-
run: |
29-
ddev config set pypi.user __token__
30-
ddev config set pypi.pass ${{ secrets.PYPI_TOKEN }}
30+
await github.rest.git.createRef({
31+
owner: context.repo.owner,
32+
repo: context.repo.repo,
33+
ref: `refs/tags/${tagName}`,
34+
sha: context.payload.pull_request.merge_commit_sha,
35+
});
3136
32-
- name: Publish the wheel to PyPI
33-
run: |
34-
ddev release upload .
37+
await github.rest.repos.createRelease({
38+
owner: context.repo.owner,
39+
repo: context.repo.repo,
40+
generate_release_notes: true,
41+
tag_name: tagName,
42+
});

0 commit comments

Comments
 (0)