|
| 1 | +name: Create Release Branch |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: 'Bioconductor version (e.g., 3.23) or "devel" to bump the devel branch' |
| 8 | + required: true |
| 9 | + default: 'devel' |
| 10 | + r_version: |
| 11 | + description: 'R version tag for base image (e.g., 4.4.2). Used for numbered releases; leave as "latest" for devel.' |
| 12 | + required: false |
| 13 | + default: 'latest' |
| 14 | + |
| 15 | +jobs: |
| 16 | + create-branch: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + steps: |
| 19 | + - name: Checkout devel branch |
| 20 | + uses: actions/checkout@v4 |
| 21 | + with: |
| 22 | + ref: devel |
| 23 | + fetch-depth: 0 |
| 24 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 25 | + |
| 26 | + - name: Configure git |
| 27 | + run: | |
| 28 | + git config user.name github-actions |
| 29 | + git config user.email github-actions@github.com |
| 30 | +
|
| 31 | + - name: Create branch, update Dockerfile, and open PR |
| 32 | + env: |
| 33 | + VERSION: ${{ github.event.inputs.version }} |
| 34 | + R_VERSION: ${{ github.event.inputs.r_version }} |
| 35 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 36 | + run: | |
| 37 | + if [ "$VERSION" == "devel" ]; then |
| 38 | + # Read current BIOCONDUCTOR_VERSION and increment the minor version |
| 39 | + CURRENT_VER=$(grep -oP '(?<=^ARG BIOCONDUCTOR_VERSION=)[0-9.]+' Dockerfile | head -1) |
| 40 | + if [ -z "$CURRENT_VER" ]; then |
| 41 | + echo "ERROR: Could not find BIOCONDUCTOR_VERSION in Dockerfile" >&2 |
| 42 | + exit 1 |
| 43 | + fi |
| 44 | + MAJOR=$(echo "$CURRENT_VER" | cut -d. -f1) |
| 45 | + MINOR=$(echo "$CURRENT_VER" | cut -d. -f2) |
| 46 | + NEW_MINOR=$((MINOR + 1)) |
| 47 | + NEW_VER="${MAJOR}.${NEW_MINOR}" |
| 48 | +
|
| 49 | + BRANCH_NAME="bump-bioc-devel-${NEW_VER}" |
| 50 | + git checkout -b "$BRANCH_NAME" |
| 51 | +
|
| 52 | + # Update both occurrences of BIOCONDUCTOR_VERSION in the Dockerfile |
| 53 | + sed -i "s/^ARG BIOCONDUCTOR_VERSION=.*/ARG BIOCONDUCTOR_VERSION=${NEW_VER}/" Dockerfile |
| 54 | + # Reset BIOCONDUCTOR_PATCH to 0 |
| 55 | + sed -i "s/^ARG BIOCONDUCTOR_PATCH=.*/ARG BIOCONDUCTOR_PATCH=0/" Dockerfile |
| 56 | +
|
| 57 | + PR_TITLE="Bump devel Bioconductor version to ${NEW_VER}" |
| 58 | + cat > /tmp/pr_body.md << EOF |
| 59 | + Automated bump of the devel \`BIOCONDUCTOR_VERSION\` from ${CURRENT_VER} to ${NEW_VER} and reset of \`BIOCONDUCTOR_PATCH\` to 0. |
| 60 | + EOF |
| 61 | + PR_BASE="devel" |
| 62 | + else |
| 63 | + # Derive release branch name from version (e.g., 3.23 -> RELEASE_3_23) |
| 64 | + BRANCH_NAME="RELEASE_$(echo "$VERSION" | tr '.' '_')" |
| 65 | + git checkout -b "$BRANCH_NAME" |
| 66 | +
|
| 67 | + # Update amd64_tag and arm64_tag to the specific R version for this release |
| 68 | + sed -i "s/^ARG amd64_tag=.*/ARG amd64_tag=${R_VERSION}/" Dockerfile |
| 69 | + sed -i "s/^ARG arm64_tag=.*/ARG arm64_tag=${R_VERSION}/" Dockerfile |
| 70 | + # Reset BIOCONDUCTOR_PATCH to 0 |
| 71 | + sed -i "s/^ARG BIOCONDUCTOR_PATCH=.*/ARG BIOCONDUCTOR_PATCH=0/" Dockerfile |
| 72 | +
|
| 73 | + PR_TITLE="Create ${BRANCH_NAME} for Bioconductor ${VERSION}" |
| 74 | + cat > /tmp/pr_body.md << EOF |
| 75 | + Automated creation of the \`${BRANCH_NAME}\` release branch for Bioconductor ${VERSION}. |
| 76 | +
|
| 77 | + Changes: |
| 78 | + - \`amd64_tag\` and \`arm64_tag\` set to \`${R_VERSION}\` |
| 79 | + - \`BIOCONDUCTOR_PATCH\` reset to 0 |
| 80 | + EOF |
| 81 | + PR_BASE="devel" |
| 82 | + fi |
| 83 | +
|
| 84 | + git add Dockerfile |
| 85 | + git commit -m "$PR_TITLE" |
| 86 | + git push --force-with-lease origin "$BRANCH_NAME" |
| 87 | +
|
| 88 | + gh pr create \ |
| 89 | + --title "$PR_TITLE" \ |
| 90 | + --body-file /tmp/pr_body.md \ |
| 91 | + --head "$BRANCH_NAME" \ |
| 92 | + --base "$PR_BASE" \ |
| 93 | + || echo "PR already exists for branch ${BRANCH_NAME}, skipping creation." |
0 commit comments