Skip to content

Commit 8aef091

Browse files
committed
Enable Auto Publish
1 parent 690b711 commit 8aef091

File tree

2 files changed

+109
-2
lines changed

2 files changed

+109
-2
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# See https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ for an example using this strategy
2+
name: Auto Publish Release
3+
on:
4+
workflow_run:
5+
workflows: ["Draft Release"]
6+
types:
7+
- completed
8+
9+
jobs:
10+
publish_release:
11+
runs-on: ubuntu-latest
12+
if: >
13+
${{ github.event.workflow_run.conclusion == 'success' }}
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v2
17+
- name: Install Python
18+
uses: actions/setup-python@v2
19+
with:
20+
python-version: 3.9
21+
architecture: "x64"
22+
- name: Install node
23+
uses: actions/setup-node@v2
24+
with:
25+
node-version: "14.x"
26+
- name: Upgrade packaging dependencies
27+
run: |
28+
pip install --upgrade pip setuptools wheel --user
29+
30+
- name: Download Draft Release URL artifact
31+
uses: actions/[email protected]
32+
with:
33+
script: |
34+
var artifacts = await github.actions.listWorkflowRunArtifacts({
35+
owner: context.repo.owner,
36+
repo: context.repo.repo,
37+
run_id: ${{github.event.workflow_run.id }},
38+
});
39+
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
40+
return artifact.name == "draft-release-url"
41+
})[0];
42+
var download = await github.actions.downloadArtifact({
43+
owner: context.repo.owner,
44+
repo: context.repo.repo,
45+
artifact_id: matchArtifact.id,
46+
archive_format: 'zip',
47+
});
48+
var fs = require('fs');
49+
fs.writeFileSync('${{github.workspace}}/url.zip', Buffer.from(download.data));
50+
51+
- name: Extract Draft Release URL
52+
id: draft-release-url
53+
run: |
54+
unzip url.zip
55+
echo "::set-output name=url::$(cat draft-release-url.txt)"
56+
57+
- name: Publish Release
58+
id: publish-release
59+
if: ${{ steps.draft-release-url.outputs.url !== "" }}
60+
env:
61+
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
62+
PYPI_TOKEN_MAP: ${{ secrets.PYPI_TOKEN_MAP }}
63+
TWINE_USERNAME: __token__
64+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
65+
uses: jupyter-server/jupyter_releaser/.github/actions/publish-release@v1
66+
with:
67+
token: ${{ secrets.ADMIN_GITHUB_TOKEN }}
68+
release_url: ${{ steps.draft-release-url.outputs.url }}
69+
70+
- name: "** Next Step **"
71+
run: |
72+
if [ ${{ steps.draft-release-url.outputs.url }} ];then
73+
echo "Verify the final release"
74+
echo ${{ steps.publish-release.outputs.release_url }}
75+
if [ ! -z "${{ steps.publish-release.outputs.pr_url }}" ]; then
76+
echo "Merge the forwardport PR"
77+
echo ${{ steps.publish-release.outputs.pr_url }}
78+
fi
79+
else
80+
echo "No Action Needed, Skipped Auto Publish"
81+
fi

.github/workflows/draft-release.yml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ on:
2020
since_last_stable:
2121
description: Use PRs with activity since the last stable git tag
2222
required: false
23+
auto_publish:
24+
description: Whether to automatically run the Auto Publish workflow
25+
default: true
26+
required: false
2327
jobs:
2428
release:
2529
runs-on: ubuntu-latest
@@ -45,6 +49,7 @@ jobs:
4549
- name: Upgrade packaging dependencies
4650
run: |
4751
pip install --upgrade pip setuptools wheel --user
52+
4853
- name: Create Draft GitHub Release
4954
id: draft-release
5055
uses: jupyter-server/jupyter_releaser/.github/actions/draft-release@v1
@@ -56,7 +61,28 @@ jobs:
5661
post_version_spec: ${{ github.event.inputs.post_version_spec }}
5762
since: ${{ github.event.inputs.since }}
5863
since_last_stable: ${{ github.event.intputs.since_last_stable }}
64+
65+
- name: "Store Auto Publish URL"
66+
run: |
67+
if [ ${{ github.events.inputs.auto_publish }} == 'true']; then
68+
echo ${{ steps.draft-release.outputs.release_url }} > "draft-release-url.txt"
69+
else:
70+
echo "Skipping auto publish"
71+
echo "" > "draft-release-url.txt"
72+
fi
73+
74+
- name: "Upload Auto Publish URL"
75+
uses: actions/upload-artifact@v2
76+
with:
77+
name: draft-release-url
78+
path: |
79+
draft-release-url.txt
80+
5981
- name: "** Next Step **"
6082
run: |
61-
echo "Run the "Publish Release" Workflow with Release Url:"
62-
echo ${{ steps.draft-release.outputs.release_url }}
83+
if [ ${{ github.events.inputs.auto_publish }} == 'true']; then
84+
echo "Wait for the 'Auto Publish workflow to complete';
85+
else
86+
echo "Run the "Publish Release" Workflow with Release Url:"
87+
echo ${{ steps.draft-release.outputs.release_url }}
88+
fi

0 commit comments

Comments
 (0)