-
Notifications
You must be signed in to change notification settings - Fork 72
136 lines (127 loc) · 5.15 KB
/
Copy pathprerelease-command.yml
File metadata and controls
136 lines (127 loc) · 5.15 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
name: On-Demand Prerelease
on:
workflow_dispatch:
inputs:
pr:
description: 'PR Number'
type: string
required: true
comment-id:
description: 'Comment ID (Optional)'
type: string
required: false
env:
AIRBYTE_ANALYTICS_ID: ${{ vars.AIRBYTE_ANALYTICS_ID }}
permissions:
contents: write
id-token: write
pull-requests: write
issues: write
jobs:
resolve-pr:
name: Set up Workflow
runs-on: ubuntu-latest
steps:
- name: Resolve workflow variables
id: vars
uses: aaronsteers/resolve-ci-vars-action@2e56afab0344bbe03c047dfa39bae559d0291472 # v0.1.6
- name: Append comment with job run link
id: first-comment-action
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
with:
comment-id: ${{ github.event.inputs.comment-id }}
issue-number: ${{ github.event.inputs.pr }}
body: |
> **Prerelease Build Started**
>
> Building and publishing prerelease package from this PR...
> [Check job output.](${{ steps.vars.outputs.run-url }})
- name: Checkout to get latest tag
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
fetch-depth: 0
- name: Compute prerelease version
id: version
run: |
# Get the latest tag version (strip 'v' prefix if present)
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
BASE_VERSION=${LATEST_TAG#v}
# Create a unique prerelease version using PR number and run ID
# Format: {base}.dev{pr_number}{run_id} (e.g., 0.34.0.dev825123456789)
PRERELEASE_VERSION="${BASE_VERSION}.dev${{ github.event.inputs.pr }}${{ github.run_id }}"
echo "version=$PRERELEASE_VERSION" >> $GITHUB_OUTPUT
echo "Computed prerelease version: $PRERELEASE_VERSION"
outputs:
source-repo: ${{ steps.vars.outputs.pr-source-repo-name-full }}
source-branch: ${{ steps.vars.outputs.pr-source-git-branch }}
commit-sha: ${{ steps.vars.outputs.pr-source-git-sha }}
pr-number: ${{ steps.vars.outputs.pr-number }}
job-run-url: ${{ steps.vars.outputs.run-url }}
first-comment-id: ${{ steps.first-comment-action.outputs.comment-id }}
prerelease-version: ${{ steps.version.outputs.version }}
build-and-publish:
name: Trigger Publish Workflow
needs: [resolve-pr]
runs-on: ubuntu-latest
steps:
- name: Authenticate as GitHub App
uses: actions/create-github-app-token@67018539274d69449ef7c02e8e71183d1719ab42 # v2.1.4
id: get-app-token
with:
owner: "airbytehq"
repositories: "PyAirbyte"
app-id: ${{ secrets.OCTAVIA_BOT_APP_ID }}
private-key: ${{ secrets.OCTAVIA_BOT_PRIVATE_KEY }}
- name: Trigger pypi_publish workflow
id: dispatch
uses: the-actions-org/workflow-dispatch@v4
with:
workflow: pypi_publish.yml
token: ${{ steps.get-app-token.outputs.token }}
ref: main # Run from main so OIDC attestation matches trusted publisher
inputs: '{"git_ref": "refs/pull/${{ github.event.inputs.pr }}/head", "version_override": "${{ needs.resolve-pr.outputs.prerelease-version }}", "publish": "true"}'
wait-for-completion: true
wait-for-completion-timeout: 30m
outputs:
workflow-conclusion: ${{ steps.dispatch.outputs.workflow-conclusion }}
workflow-url: ${{ steps.dispatch.outputs.workflow-url }}
post-result-comment:
name: Write Status to PR
needs: [resolve-pr, build-and-publish]
if: always()
runs-on: ubuntu-latest
steps:
- name: Post success comment
if: needs.build-and-publish.result == 'success'
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
with:
comment-id: ${{ needs.resolve-pr.outputs.first-comment-id }}
issue-number: ${{ github.event.inputs.pr }}
reactions: rocket
body: |
> **Prerelease Published to PyPI**
>
> Version: `${{ needs.resolve-pr.outputs.prerelease-version }}`
> [View publish workflow](${{ needs.build-and-publish.outputs.workflow-url }})
>
> Install with:
> ```bash
> pip install airbyte==${{ needs.resolve-pr.outputs.prerelease-version }}
> ```
- name: Post failure comment
if: needs.build-and-publish.result == 'failure'
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
with:
comment-id: ${{ needs.resolve-pr.outputs.first-comment-id }}
issue-number: ${{ github.event.inputs.pr }}
reactions: confused
body: |
> **Prerelease Build/Publish Failed**
>
> The prerelease encountered an error.
> [Check publish workflow output](${{ needs.build-and-publish.outputs.workflow-url }}) for details.
>
> You can still install directly from this PR branch:
> ```bash
> pip install 'git+https://github.com/${{ needs.resolve-pr.outputs.source-repo }}.git@${{ needs.resolve-pr.outputs.source-branch }}'
> ```