-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a release action #497
Draft
melissawm
wants to merge
8
commits into
napari:main
Choose a base branch
from
melissawm:release-action
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Add a release action #497
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5443880
Add a release action
melissawm 369746c
Fix release action execution condition
melissawm 7816720
Add condition to filter out release candidates from release action
melissawm a9e9297
Add script to update version switcher
melissawm b8260e9
Merge branch 'main' into release-action
melissawm 00094bf
Merge branch 'main' into release-action
melissawm 050b300
Bump actions for actionlint
melissawm 59135d3
Bump action
melissawm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,11 +69,23 @@ jobs: | |
python -c 'import napari.layers; print(napari.layers.__doc__)' | ||
|
||
- name: Create fallback videos | ||
# Only needed for deployment, so should **NOT** be in | ||
# napari/napari/.github/workflows/build_docs.yml | ||
run: | | ||
sudo apt-get update && sudo apt-get install -y ffmpeg | ||
cd docs | ||
make fallback-videos | ||
|
||
- name: Update version switcher (on new release) | ||
if: ((github.event_name == 'release' && !contains(github.event.release.tag_name, 'rc')) || (github.event_name == 'workflow_dispatch' && github.event.inputs.target_directory != 'dev')) | ||
run: | | ||
cd docs | ||
python docs/_scripts/update_switcher.py ${{ github.event.inputs.target_directory || github.event.release.tag_name }} | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "GitHub Action" | ||
git add docs/_static/version_switcher.json | ||
git commit -m "Update version switcher for release" --allow-empty | ||
|
||
- name: Build Docs | ||
uses: aganders3/headless-gui@v2 | ||
env: | ||
|
@@ -109,13 +121,55 @@ jobs: | |
# Downloads to '/home/runner/work/docs/docs/html' | ||
path: html | ||
|
||
- name: Deploy Docs | ||
- name: Deploy Dev Docs | ||
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && (startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/main')) | ||
uses: peaceiris/actions-gh-pages@v3 | ||
uses: peaceiris/actions-gh-pages@v4 | ||
with: | ||
# Note that GITHUB_TOKEN has no permission to access to external repositories. | ||
# When you use deploy_key, set your private key to the repository which | ||
# includes this action as a secret, and set your public key to your external repository. | ||
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }} | ||
external_repository: napari/napari.github.io | ||
publish_dir: ./html | ||
publish_branch: gh-pages | ||
destination_dir: ${{ github.event.inputs.target_directory || 'dev' }} | ||
cname: napari.org | ||
keep_files: true | ||
|
||
# Because we are using two deploy actions, we need to reset the ssh-agent | ||
# to avoid the following error: | ||
# unix_listener: cannot bind to path /tmp/ssh-auth.sock: Address already in use | ||
# See https://github.com/peaceiris/actions-gh-pages/issues/909 | ||
- name: Reset ssh agent | ||
if: ((github.event_name == 'release' && !contains(github.event.release.tag_name, 'rc')) || (github.event_name == 'workflow_dispatch' && github.event.inputs.target_directory != 'dev')) | ||
run: killall ssh-agent | ||
|
||
# Because the actions-gh-pages triggers a pages deployment, it can be some | ||
# time before the repo is updated. We need to wait for the deployment to | ||
# complete before we can create a second deployment, or we will have a git | ||
# conflict. The 5m sleep is completely arbitrary. | ||
- name: Wait for first deployment | ||
if: ((github.event_name == 'release' && !contains(github.event.release.tag_name, 'rc')) || (github.event_name == 'workflow_dispatch' && github.event.inputs.target_directory != 'dev')) | ||
run: sleep 5m | ||
|
||
- name: Deploy Release Docs | ||
if: ((github.event_name == 'release' && !contains(github.event.release.tag_name, 'rc')) || (github.event_name == 'workflow_dispatch' && github.event.inputs.target_directory != 'dev')) | ||
uses: peaceiris/actions-gh-pages@v4 | ||
with: | ||
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }} | ||
external_repository: napari/napari.github.io | ||
publish_dir: ./html | ||
publish_branch: gh-pages | ||
destination_dir: ${{ github.event.inputs.target_directory || github.event.release.tag_name }} | ||
cname: napari.org | ||
keep_files: true | ||
|
||
- name: Set up stable symlink | ||
if: ((github.event_name == 'release' && !contains(github.event.release.tag_name, 'rc')) || (github.event_name == 'workflow_dispatch' && github.event.inputs.target_directory != 'dev')) | ||
uses: convictional/[email protected] | ||
with: | ||
owner: napari | ||
repo: napari.github.io | ||
github_token: ${{ secrets.WORKFLOW_PAT }} | ||
workflow_file_name: symlink-stable.yml | ||
client_payload: '{"target_directory": "${{ github.event.inputs.target_directory || github.event.release.tag_name }}"}' | ||
melissawm marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import sys | ||
import json | ||
|
||
|
||
def update_version_switcher(new_version): | ||
"""Update version_switcher.json after a new release.""" | ||
with open("docs/_static/version_switcher.json", "r") as f: | ||
switcher = json.load(f) | ||
oldstable = switcher[1] | ||
|
||
newstable = oldstable.copy() | ||
newstable["version"] = new_version | ||
newstable["name"] = f"stable ({new_version})" | ||
|
||
oldstable["name"] = f"{oldstable['version']}" | ||
del oldstable["preferred"] | ||
oldstable["url"] = oldstable["url"].replace("stable", oldstable["version"]) | ||
|
||
switcher[1] = oldstable | ||
switcher.insert(1, newstable) | ||
with open("docs/_static/version_switcher.json", "w") as f: | ||
json.dump(switcher, f, indent=4) | ||
|
||
print(f"Version switcher updated to {new_version}") | ||
print(f"Old stable version: {switcher[2]}") | ||
print(f"New stable version: {switcher[1]}") | ||
|
||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) != 2: | ||
print("Usage: python update_switcher.py <new_version>") | ||
sys.exit() | ||
new_version = sys.argv[1] | ||
update_version_switcher(new_version) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could potentially create a wrong folder if the wrong version string is passed as input to the action.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how to validate this entry :(