2023-01-16 02:35:21 +00:00
|
|
|
name: release
|
|
|
|
|
|
|
|
on:
|
2023-07-21 16:20:24 +00:00
|
|
|
workflow_call:
|
|
|
|
inputs:
|
|
|
|
working-directory:
|
|
|
|
required: true
|
|
|
|
type: string
|
|
|
|
description: "From which folder this pipeline executes"
|
2023-01-16 02:35:21 +00:00
|
|
|
|
|
|
|
env:
|
2023-08-21 14:35:56 +00:00
|
|
|
POETRY_VERSION: "1.5.1"
|
2023-01-16 02:35:21 +00:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
if_release:
|
|
|
|
if: |
|
:bug: fix unexpected run of release workflow (#9494)
I have discovered a bug located within `.github/workflows/_release.yml`
which is the primary cause of continuous integration (CI) errors. The
problem can be solved; therefore, I have constructed a PR to address the
issue.
## The Issue
Access the following link to view the exact errors: [Langhain Release
Workflow](https://github.com/langchain-ai/langchain/actions/workflows/langchain_release.yml)
The instances of these errors take place for **each PR** that updates
`pyproject.toml`, excluding those specifically associated with bumping
PRs.
See below for the specific error message:
```
Error: Error 422: Validation Failed: {"resource":"Release","code":"already_exists","field":"tag_name"}
```
An image of the error can be viewed here:
![Image](https://github.com/langchain-ai/langchain/assets/13769670/13125f73-9b53-49b7-a83e-653bb01a1da1)
The `_release.yml` document contains the following if-condition:
```yaml
if: |
${{ github.event.pull_request.merged == true }}
&& ${{ contains(github.event.pull_request.labels.*.name, 'release') }}
```
## The Root Cause
The above job constantly runs as the `if-condition` is always identified
as `true`.
## The Logic
The `if-condition` can be defined as `if: ${{ b1 }} && ${{ b2 }}`, where
`b1` and `b2` are boolean values. However, in terms of condition
evaluation with GitHub Actions, `${{ false }}` is identified as a string
value, thereby rendering it as truthy as per the [official
documentation](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idif).
I have run some tests regarding this behavior within my forked
repository. You can consult my [debug
PR](https://github.com/zawakin/langchain/pull/1) for reference.
Here is the result of the tests:
|If-Condition|Outcome|
|:--:|:--:|
|`if: true && ${{ false }}`|Execution|
|`if: ${{ false }}` |Skipped|
|`if: true && false` |Skipped|
|`if: false`|Skipped|
|`if: ${{ true && false }}` |Skipped|
In view of the first and second results, we can infer that `${{ false
}}` can only be interpreted as `true` for conditions composed of some
expressions.
It is consistent that the condition of `if: ${{ inputs.working-directory
== 'libs/langchain' }}` works.
It is surprised to be skipped for the second case but it seems the spec
of GitHub Actions 😓
Anyway, the PR would fix these errors, I believe 👍
Could you review this? @hwchase17 or @shoelsch , who is the author of
[PR](https://github.com/langchain-ai/langchain/pull/360).
2023-08-21 14:34:03 +00:00
|
|
|
github.event.pull_request.merged == true
|
|
|
|
&& contains(github.event.pull_request.labels.*.name, 'release')
|
2023-01-16 02:35:21 +00:00
|
|
|
runs-on: ubuntu-latest
|
2023-07-21 16:20:24 +00:00
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
working-directory: ${{ inputs.working-directory }}
|
2023-01-16 02:35:21 +00:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Install poetry
|
2023-08-21 14:35:56 +00:00
|
|
|
run: pipx install "poetry==$POETRY_VERSION"
|
2023-01-16 02:35:21 +00:00
|
|
|
- name: Set up Python 3.10
|
|
|
|
uses: actions/setup-python@v4
|
|
|
|
with:
|
|
|
|
python-version: "3.10"
|
|
|
|
cache: "poetry"
|
|
|
|
- name: Build project for distribution
|
|
|
|
run: poetry build
|
|
|
|
- name: Check Version
|
|
|
|
id: check-version
|
|
|
|
run: |
|
|
|
|
echo version=$(poetry version --short) >> $GITHUB_OUTPUT
|
|
|
|
- name: Create Release
|
|
|
|
uses: ncipollo/release-action@v1
|
2023-07-29 00:16:51 +00:00
|
|
|
if: ${{ inputs.working-directory == 'libs/langchain' }}
|
2023-01-16 02:35:21 +00:00
|
|
|
with:
|
|
|
|
artifacts: "dist/*"
|
|
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
draft: false
|
|
|
|
generateReleaseNotes: true
|
|
|
|
tag: v${{ steps.check-version.outputs.version }}
|
|
|
|
commit: master
|
|
|
|
- name: Publish to PyPI
|
|
|
|
env:
|
|
|
|
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }}
|
2023-04-25 01:19:51 +00:00
|
|
|
run: |
|
2023-01-16 02:35:21 +00:00
|
|
|
poetry publish
|