Skip to content

Commit

Permalink
ci: dynamically choose correct release branch
Browse files Browse the repository at this point in the history
Choose correct release branch (e.g. `v1` or `v2`) based on the released version. Determine the major version from `GITHUB_REF` and push to the corresponding release branch.

Switch to strategy `fail` as merges into the release branch should neither necessary nor desirable.
  • Loading branch information
jojomatik committed Oct 11, 2022
1 parent 59149dd commit a8f60fa
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,28 @@ jobs:
git_committer_name: ${{ secrets.BUMP_GIT_NAME }}
git_committer_email: ${{ secrets.BUMP_GIT_EMAIL }}
github_token: ${{ secrets.GH_TOKEN }}
sync_main_to_v1:
sync_release_to_vx:
if: |
always() &&
(needs.semantic-release.result == 'success' || needs.semantic-release.result == 'skipped') &&
(startsWith(github.ref, 'refs/tags/v1') && !contains(github.ref, 'beta'))
name: Sync branch `main` to `v1` (fast-forward enabled)
(startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, 'beta'))
name: Sync new release to `vx`-branch
runs-on: ubuntu-latest
needs:
- semantic-release
steps:
- name: Keep `v1` up to date with `main` (fast-forward enabled)
- name: Get version
id: version
run: echo ::set-output name=version::${GITHUB_REF#refs/tags/}
- name: Get major version
id: major
run: version=${{ steps.version.outputs.version }} && echo ::set-output name=major::${version%%.*}
- name: Keep `vx` up to date with new release
uses: jojomatik/sync-branch@beta
with:
source: "main"
target: "v1"
source: ${{ github.ref }}
target: ${{ format('refs/heads/{0}', steps.major.outputs.major) }}
strategy: "fail"
git_committer_name: ${{ secrets.BUMP_GIT_NAME }}
git_committer_email: ${{ secrets.BUMP_GIT_EMAIL }}
github_token: ${{ secrets.GH_TOKEN }}
github_token: ${{ secrets.GH_TOKEN }}

0 comments on commit a8f60fa

Please sign in to comment.