Skip to content

Commit 73b42f0

Browse files
Diana Liskovichfacebook-github-bot
authored andcommitted
Refactor release.yml (#4475)
Summary: # Before submitting - [ ] Was this discussed/approved via a Github issue? (no need for typos, doc improvements) - [ ] Did you read the [contributor guideline](https://github.com/pytorch/fairseq/blob/main/CONTRIBUTING.md)? - [ ] Did you make sure to update the docs? - [ ] Did you write any new necessary tests? ## What does this PR do? Fixes # (issue). ## PR review Anyone in the community is free to review the PR once the tests have passed. If we didn't discuss your PR in Github issues there's a high chance it will not be merged. ## Did you have fun? Make sure you had fun coding � Pull Request resolved: #4475 Reviewed By: anupambhatnagar Differential Revision: D37081823 Pulled By: dianaml0 fbshipit-source-id: b5167aa66e0b873c5f466e1b16a27ca779802780
1 parent fea865c commit 73b42f0

File tree

2 files changed

+76
-35
lines changed

2 files changed

+76
-35
lines changed

.github/workflows/release.yml

Lines changed: 75 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,74 @@ jobs:
2424
- name: get next version and tag
2525
id: get-next-version-and-tag
2626
run: |
27-
output=$(python3 release_utils.py --release-type ${{ github.event.inputs.name }})
27+
output=$(python3 release_utils.py --release-type ${{ github.event.inputs.name }})
2828
echo $output
2929
new_version=$(echo $output | awk '{print $1}')
3030
new_tag=$(echo $output | awk '{print $2}')
3131
echo "new version is $new_version"
3232
echo "new tag is $new_tag"
3333
echo ::set-output name=version::$new_version
3434
echo ::set-output name=tag::$new_tag
35+
echo ::set-output name=branch_name::$new_version-release
36+
echo "NEW_TAG=$new_tag" >> $GITHUB_ENV
37+
echo "NEW_BRANCH=$new_version-release" >> $GITHUB_ENV
38+
39+
40+
# update the version number in version.txt
41+
- name: update version
42+
id: update-version
43+
run : |
44+
echo "current folder = $PWD"
45+
echo "current branch = $(git branch --show-current)"
46+
output=$(python3 release_utils.py --release-type ${{ github.event.inputs.name }} --update-version)
47+
48+
- name: add and commit
49+
uses: EndBug/add-and-commit@v9
50+
with:
51+
author_name: ${{ secrets.AUTHOR_NAME }}
52+
author_email: ${{ secrets.AUTHOR_EMAIL }}
53+
54+
# TODO: change this to main once shipit is disabled.
55+
new_branch: '${{ env.NEW_BRANCH }}'
56+
default_author: github_actor
57+
message: '${{ env.NEW_TAG }} release'
58+
pathspec_error_handling: exitAtEnd
59+
60+
# Arguments for the git pull command. Use NO-PULL to avoid the action pulling at all.
61+
# pull: 'NO-PULL'
62+
tag: '${{ env.NEW_TAG }}'
63+
3564
outputs:
3665
new_version: ${{ steps.get-next-version-and-tag.outputs.version }}
3766
new_tag: ${{ steps.get-next-version-and-tag.outputs.tag }}
67+
branch_name: ${{ steps.get-next-version-and-tag.outputs.branch_name }}
68+
69+
create_sdist:
70+
runs-on: ubuntu-latest
71+
name: Create Source Distribution
72+
needs: get_next_version
73+
steps:
74+
- uses: actions/checkout@v3
75+
with:
76+
ref: ${{ needs.get_next_version.outputs.branch_name }}
77+
78+
- name: Install Python
79+
uses: actions/setup-python@v2
80+
with:
81+
python-version: '3.8'
82+
83+
- name: Upgrade pip
84+
run: |
85+
python3 -m pip install --upgrade pip
86+
87+
- name: Create Source Distribution
88+
run: |
89+
pip install setuptools wheel twine
90+
python3 setup.py sdist
91+
92+
- uses: actions/upload-artifact@v2
93+
with:
94+
path: dist/*.tar.gz
3895

3996
build_wheels:
4097
name: Build wheels on ${{ matrix.os }}
@@ -45,30 +102,19 @@ jobs:
45102
os: [ubuntu-latest, macos-latest]
46103

47104
steps:
48-
- uses: actions/checkout@v2
105+
- uses: actions/checkout@v3
106+
with:
107+
ref: ${{ needs.get_next_version.outputs.branch_name }}
49108

50109
- name: Install Python
51110
uses: actions/setup-python@v2
52111
with:
53112
python-version: '3.8'
54113

55-
# update the version number in version.txt
56-
- name: update version
57-
id: update-version
58-
run : |
59-
echo "current folder = $PWD"
60-
echo "current branch = $(git branch --show-current)"
61-
output=$(python3 release_utils.py --release-type ${{ github.event.inputs.name }} --update-version)
62-
63114
- name: Upgrade pip
64115
run: |
65116
python3 -m pip install --upgrade pip
66117
67-
- name: Create Source Distribution
68-
run: |
69-
pip install setuptools wheel twine
70-
python3 setup.py sdist
71-
72118
- name: Install cibuildwheel
73119
run: |
74120
python3 -m pip install cibuildwheel
@@ -85,6 +131,20 @@ jobs:
85131
CIBW_ENVIRONMENT: "PIP_ONLY_BINARY=numpy"
86132
CIBW_SKIP: "*musllinux*"
87133

134+
- uses: actions/upload-artifact@v2
135+
with:
136+
path: dist
137+
138+
upload:
139+
name: Upload to PyPi and create release
140+
runs-on: ubuntu-latest
141+
needs: [build_wheels, create_sdist, get_next_version]
142+
steps:
143+
- uses: actions/download-artifact@v2
144+
with:
145+
name: artifact
146+
path: dist
147+
88148
# build the PyPI package and upload it
89149
- name: upload
90150
env:
@@ -93,27 +153,8 @@ jobs:
93153
run: |
94154
python3 -m twine upload --repository pypi dist/*
95155
96-
# add and commit the updated version.py to main
97-
- name: add and commit
98-
if: ${{ matrix.os=='ubuntu-latest' }}
99-
uses: EndBug/add-and-commit@v9
100-
with:
101-
author_name: ${{ secrets.AUTHOR_NAME }}
102-
author_email: ${{ secrets.AUTHOR_EMAIL }}
103-
104-
# TODO: change this to main once shipit is disabled.
105-
new_branch: ${{ needs.get_next_version.outputs.new_version }}
106-
default_author: github_actor
107-
message: '${{ needs.get_next_version.outputs.new_version }} release'
108-
pathspec_error_handling: exitAtEnd
109-
110-
# Arguments for the git pull command. Use NO-PULL to avoid the action pulling at all.
111-
# pull: 'NO-PULL'
112-
tag: '${{ needs.get_next_version.outputs.new_tag }}'
113-
114156
# create the release on github
115157
- name: create release on github
116-
if: ${{ matrix.os=='ubuntu-latest' }}
117158
uses: ncipollo/release-action@v1
118159
with:
119160
tag: '${{ needs.get_next_version.outputs.new_tag }}'

RELEASE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ In order to create a new release:
66

77
2. Under _Run Workflow_ choose the branch `main` and for _Release Type_ enter either `major`, `minor`, or `patch`.
88

9-
3. A branch with the same name as the new version will be created where the `version.txt` file is updated. Merge those changes into `main`.
9+
3. A branch named `$new_version-release` will be created where the `version.txt` file is updated. Merge those changes into `main`.
1010

1111
4. Make sure that a [new PYPI package](https://pypi.org/project/fairseq/) has been uploaded.
1212

0 commit comments

Comments
 (0)