|
| 1 | +name: Sync winget-release-workflow fork branch with upstream master |
| 2 | +# Default branch set to winget-release-workflow rather than master so action can run, and changes only occur in that branch so master is synced. |
| 3 | + |
| 4 | +on: |
| 5 | + schedule: |
| 6 | + - cron: '0 3 * * *' # daily at 03:00 UTC |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +jobs: |
| 10 | + sync-master: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - name: Checkout fork master |
| 14 | + uses: actions/checkout@v4 |
| 15 | + with: |
| 16 | + ref: master |
| 17 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 18 | + |
| 19 | + - name: Add upstream remote |
| 20 | + run: | |
| 21 | + git remote add upstream https://github.com/libvips/build-win64-mxe.git || true |
| 22 | + git fetch upstream master --tags |
| 23 | +
|
| 24 | + - name: Hard reset fork master to upstream |
| 25 | + run: | |
| 26 | + git checkout master |
| 27 | + git reset --hard upstream/master |
| 28 | + git push origin master --force |
| 29 | +
|
| 30 | + sync-winget-branch: |
| 31 | + runs-on: ubuntu-latest |
| 32 | + needs: sync-master |
| 33 | + steps: |
| 34 | + - name: Checkout fork branch |
| 35 | + uses: actions/checkout@v4 |
| 36 | + with: |
| 37 | + ref: winget-release-workflow |
| 38 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 39 | + |
| 40 | + - name: Add upstream remote |
| 41 | + run: | |
| 42 | + git remote add upstream https://github.com/libvips/build-win64-mxe.git || true |
| 43 | + git fetch upstream master --tags |
| 44 | +
|
| 45 | + - name: Configure Git identity |
| 46 | + run: | |
| 47 | + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 48 | + git config --global user.name "github-actions[bot]" |
| 49 | +
|
| 50 | + - name: Rebase winget-release-workflow on upstream/master |
| 51 | + run: | |
| 52 | + git checkout winget-release-workflow |
| 53 | + git rebase upstream/master || (git rebase --abort && exit 1) |
| 54 | + git push origin winget-release-workflow --force |
| 55 | +
|
| 56 | + - name: Push latest upstream tag |
| 57 | + run: | |
| 58 | + # find latest tag by commit date |
| 59 | + LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`) |
| 60 | + echo "Latest upstream tag: $LATEST_TAG" |
| 61 | + echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV |
| 62 | + # check if tag exists in fork |
| 63 | + if ! git ls-remote --tags origin | grep -q "refs/tags/$LATEST_TAG"; then |
| 64 | + git push origin $LATEST_TAG |
| 65 | + echo "Pushed latest tag to fork: $LATEST_TAG" |
| 66 | + else |
| 67 | + echo "Tag already exists in fork: $LATEST_TAG" |
| 68 | + fi |
| 69 | + |
| 70 | + - name: Create GitHub release for latest tag |
| 71 | + uses: ncipollo/release-action@v1 |
| 72 | + if: github.event_name == 'workflow_dispatch' || steps.push_tag.outputs.pushed == 'true' || !github.event_name |
| 73 | + with: |
| 74 | + tag: ${{ env.LATEST_TAG }} |
| 75 | + generateReleaseNotes: true |
| 76 | + skipIfReleaseExists: true |
0 commit comments