Skip to content
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

Switch to reusable workflow #80

Merged
merged 1 commit into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions .github/workflows/assign_reviewers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,5 @@ on:
pull_request_target:
types: [opened, ready_for_review]
jobs:
assign:
runs-on: ubuntu-latest
if: github.event.pull_request.assignee == null
steps:
- name: Assign reviewer
uses: kentaro-m/auto-assign-action@v1.2.4
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
assign-reviewer:
uses: khanlab/actions/.github/workflows/assign_reviewers.yml@main
63 changes: 4 additions & 59 deletions .github/workflows/bump_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,63 +4,8 @@ on:
pull_request_target:
types: [closed]
jobs:
build:
bump-version:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout master branch
uses: actions/checkout@master
with:
ref: ${{ github.event.pull_request.base.ref }}
- name: Update changelog
uses: release-drafter/release-drafter@v5
id: release-drafter
with:
commitish: ${{ github.event.pull_request.base.ref }}
env:
GITHUB_TOKEN: ${{ secrets.BP_PAT_TOKEN }}
- name: Get previous release version
run: |
echo "PREV_VER=$(cat pyproject.toml | grep -o -E '(version\s=\s)([[:punct:]])([0-9]+\.[0-9]+\.[0-9]+.+)([[:punct:]])' | cut -d ' ' -f 3 | tr -d '"')" >> $GITHUB_ENV
- name: Get previous bump version
env:
PREV_VER: ${{ env.PREV_VER }}
run: |
if [[ "$PREV_VER" != *"-pre."* ]]; then
echo "OLD_BUMP=0" >> $GITHUB_ENV
else
echo "OLD_BUMP=$(echo $PREV_VER | cut -d '.' -f 4)" >> $GITHUB_ENV
fi
- name: Bump version
env:
BUMP_VER: ${{ env.OLD_BUMP }}
run: |
echo "NEW_BUMP=$(($BUMP_VER + 1))" >> $GITHUB_ENV
- name: Set new release version
env:
RD_RELEASE: ${{ steps.release-drafter.outputs.name }}
run: |
if [ ! -z "$RD_RELEASE" ]; then
echo "NEW_RELEASE=$RD_RELEASE" >> $GITHUB_ENV
else
echo "NEW_RELEASE=0.1.0" >> $GITHUB_ENV
fi
- name: Update version in pyproject.toml
uses: jacobtomlinson/gha-find-replace@master
with:
include: pyproject.toml
find: version = "(?:([0-9]+\.[0-9]+\.[0-9]+.+)|([0-9]+\.[0-9]+\.[0-9]+))"
replace: version = "${{ env.NEW_RELEASE }}-pre.${{ env.NEW_BUMP }}"
- name: Commit updates
env:
SNAKEBIDS_VERSION: ${{ env.NEW_RELEASE }}-pre.${{ env.NEW_BUMP }}
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git diff-index --quiet HEAD || git commit -m "Bump version to $SNAKEBIDS_VERSION" -a
- name: Push changes
uses: CasperWA/push-protected@v2
with:
branch: ${{ github.event.pull_request.base.ref }}
token: ${{ secrets.BP_PAT_TOKEN }}
unprotect_reviews: true
uses: khanlab/actions/.github/workflows/versioning/gh_semver.yml@main
secrets:
BP_PAT: ${{ secrets.BP_PAT_TOKEN }}
12 changes: 12 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
name: Deploy packages
on:
workflow_dispatch:
push:
tags: [v*]
jobs:
deploy_docker:
uses: khanlab/actions/.github/workflows/release/docker.yml@main
with:
maximize_space: true
secrets: inherit
42 changes: 0 additions & 42 deletions .github/workflows/deploy_docker.yml

This file was deleted.

76 changes: 7 additions & 69 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,72 +7,10 @@ on:
description: Comments
required: false
jobs:
release_changelog:
runs-on: ubuntu-latest
steps:
- name: Print author
run: |
echo "Author: ${{ github.triggering_actor }}"
echo "Comments: ${{ github.event.inputs.comments }}"
- name: Extract branch name
shell: bash
id: extract_branch
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
- uses: actions/checkout@master
with:
ref: ${{ steps.extract_branch.outputs.branch }}
- name: Draft change log
uses: release-drafter/release-drafter@v5
id: release-drafter
with:
commitish: ${{ steps.extract_branch.outputs.branch }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set new release version
env:
RD_RELEASE: ${{ steps.release-drafter.outputs.name }}
run: |
if [ ! -z "$RD_RELEASE" ]; then
echo "NEW_RELEASE=$RD_RELEASE" >> $GITHUB_ENV
else
echo "NEW_RELEASE=0.1.0" >> $GITHUB_ENV
fi
- name: Update pipeline description
uses: jacobtomlinson/gha-find-replace@master
with:
include: scattr/pipeline_description.json
find: '"Version": "(?:([0-9]+\.[0-9]+\.[0-9]+.+)|([0-9]+\.[0-9]+\.[0-9]+))"'
replace: '"Version": "${{ env.NEW_RELEASE }}"'
- name: Update version in pyproject.toml
uses: jacobtomlinson/gha-find-replace@master
with:
include: pyproject.toml
find: version = "(?:([0-9]+\.[0-9]+\.[0-9]+.+)|([0-9]+\.[0-9]+\.[0-9]+))"
replace: version = "${{ env.NEW_RELEASE }}"
- name: Update container version
uses: jacobtomlinson/gha-find-replace@master
with:
include: scattr/config/snakebids.yml
find: 'scattr: "docker://khanlab/scattr:v(?:([0-9]+\.[0-9]+\.[0-9]+.+)|([0-9]+\.[0-9]+\.[0-9]+))"'
replace: 'scattr: "docker://khanlab/scattr:v${{ env.NEW_RELEASE }}"'
- name: Commit updates
env:
LATEST_VERSION: ${{ env.NEW_RELEASE }}
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git diff-index --quiet HEAD || git commit -m "Bump version to $LATEST_VERSION" -a
- name: Push changes
uses: CasperWA/push-protected@v2
with:
token: ${{ secrets.BP_PAT_TOKEN }}
unprotect_reviews: true
- name: Publish change log
uses: release-drafter/release-drafter@v5
with:
commitish: ${{ steps.extract_branch_outputs.branch }}
publish: true
name: ${{ env.NEW_RELEASE }}
tag: v${{ env.NEW_RELEASE }}
env:
GITHUB_TOKEN: ${{ secrets.BP_PAT_TOKEN }}
release_package:
uses: khanlab/actions/.github/workflows/release/gh_release.yml@main
with:
comments: ${{ github.event.inputs.comments }}
pipeline_description: true
secrets:
BP_PAT: ${{ secrets.BP_PAT_TOKEN }}