Skip to content

Commit

Permalink
Don't hardcore organisation in reusable workflow (make it an optional…
Browse files Browse the repository at this point in the history
… parameter)
  • Loading branch information
ericpre committed May 3, 2024
1 parent e9fc394 commit c5376fc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ on:
description: 'Whether to check the links in the documentation'
default: true
type: boolean

ORGANISATION:
description: 'The organisation hosting the upstream code'
default: 'hyperspy'
type: string

jobs:
build:
Expand All @@ -58,11 +61,11 @@ jobs:
echo "REPOSITORY_NAME=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV
- name: Fetch tags upstream
if: ${{ github.repository_owner != 'hyperspy' }}
if: ${{ github.repository_owner != inputs.ORGANISATION }}
# Needs to fetch the tags from upstream to get the
# correct version with setuptools_scm
run: |
git remote add upstream https://github.com/hyperspy/${{env.REPOSITORY_NAME}}.git
git remote add upstream https://github.com/${{ inputs.ORGANISATION }}/${{ env.REPOSITORY_NAME }}.git
git fetch upstream --tags
- name: Install package in Ubuntu
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/package_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ on:
# if empty string, no argument is passed
default: ''
type: string

ORGANISATION:
description: 'The organisation hosting the upstream code'
default: 'hyperspy'
type: string

env:
PYTHON_VERSION: '3.11'
Expand All @@ -58,11 +61,11 @@ jobs:
run: echo "REPOSITORY_NAME=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV

- name: Fetch tags upstream
if: ${{ github.repository_owner != 'hyperspy' }}
if: ${{ github.repository_owner != inputs.ORGANISATION }}
# Needs to fetch the tags from upstream to get the
# correct version with setuptools_scm
run: |
git remote add upstream https://github.com/hyperspy/${{ env.REPOSITORY_NAME }}.git
git remote add upstream https://github.com/${{ inputs.ORGANISATION }}/${{ env.REPOSITORY_NAME }}.git
git fetch upstream --tags
- uses: actions/setup-python@v5
Expand Down
15 changes: 12 additions & 3 deletions .github/workflows/release_pure_python.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
# This workflow can't be used as reusable workflow because it is
# concurrently not compatible with trusted publisher
# https://github.com/pypa/gh-action-pypi-publish/issues/166

name: Release

on:
workflow_call
workflow_call:
inputs:
ORGANISATION:
description: 'The organisation hosting the upstream code'
default: 'hyperspy'
type: string

jobs:
package_and_test:
Expand All @@ -26,7 +35,7 @@ jobs:
working-directory: dist

- uses: pypa/gh-action-pypi-publish@release/v1
if: ${{ startsWith(github.ref, 'refs/tags/') && github.repository_owner == 'hyperspy' }}
if: ${{ startsWith(github.ref, 'refs/tags/') && github.repository_owner == inputs.ORGANISATION }}
# See https://docs.pypi.org/trusted-publishers/using-a-publisher/

create_github_release:
Expand All @@ -41,5 +50,5 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
- name: Create Release
if: ${{ startsWith(github.ref, 'refs/tags/') && github.repository_owner == 'hyperspy' }}
if: ${{ startsWith(github.ref, 'refs/tags/') && github.repository_owner == inputs.ORGANISATION }}
uses: softprops/action-gh-release@9d7c94cfd0a1f3ed45544c887983e9fa900f0564

0 comments on commit c5376fc

Please sign in to comment.