|
| 1 | +name: Patch upstream release |
| 2 | +run-name: Apply patches to release ${{ inputs.tag }} |
| 3 | + |
| 4 | +on: |
| 5 | + workflow_dispatch: |
| 6 | + inputs: |
| 7 | + tag: |
| 8 | + description: 'Specify an upstream version tag' |
| 9 | + required: true |
| 10 | + default: 'v1.23.1' |
| 11 | + |
| 12 | +jobs: |
| 13 | + patch-upstream: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + permissions: |
| 16 | + contents: write |
| 17 | + pull-requests: write |
| 18 | + actions: write |
| 19 | + steps: |
| 20 | + - name: Checkout current branch |
| 21 | + uses: actions/checkout@v3 |
| 22 | + |
| 23 | + - name: Move patches |
| 24 | + run: mv patches /tmp/patches |
| 25 | + |
| 26 | + - name: Add upstream and fetch tags |
| 27 | + run: | |
| 28 | + git remote add upstream https://github.com/go-gitea/gitea.git |
| 29 | + git fetch upstream --tags |
| 30 | +
|
| 31 | + - name: Verify upstream tag exists |
| 32 | + run: | |
| 33 | + if ! git rev-parse "refs/tags/${{ inputs.tag }}" >/dev/null 2>&1; then |
| 34 | + echo "Error: Tag ${{ inputs.tag }} does not exist upstream." |
| 35 | + exit 1 |
| 36 | + fi |
| 37 | +
|
| 38 | + - name: Create branch from determined tag |
| 39 | + run: git checkout tags/${{ inputs.tag }} -b apply-patches-${{ inputs.tag }} |
| 40 | + |
| 41 | + - name: Configure Git user |
| 42 | + run: | |
| 43 | + git config --global user.name 'Bart van der Braak' |
| 44 | + git config --global user.email '[email protected]' |
| 45 | +
|
| 46 | + - name: Apply patches |
| 47 | + run: | |
| 48 | + if ! git am --3way /tmp/patches/*.patch; then |
| 49 | + echo "Patch application failed." |
| 50 | + git am --abort |
| 51 | + exit 1 |
| 52 | + fi |
| 53 | +
|
| 54 | + - name: Clean tags and push new |
| 55 | + run: | |
| 56 | + git tag -d "${{ inputs.tag }}" || echo "Local tag does not exist, skipping delete." |
| 57 | + git push --delete origin "${{ inputs.tag }}" || echo "Remote tag does not exist, skipping delete." |
| 58 | + git tag -a "${{ inputs.tag }}" -m "Tagging version ${{ inputs.tag }} after applying patches" |
| 59 | + git push origin "${{ inputs.tag }}" |
| 60 | + echo '{"ref":"${{ inputs.tag }}"}' | gh workflow run build.yml --ref "ci" --repo "blender/gitea" --json |
| 61 | + env: |
| 62 | + GH_TOKEN: ${{ github.token }} |
| 63 | + |
| 64 | + - name: Push branch |
| 65 | + if: always() |
| 66 | + run: git push origin apply-patches-${{ inputs.tag }} --force |
| 67 | + env: |
| 68 | + PAT_TOKEN: ${{ secrets.PAT_TOKEN }} |
| 69 | + |
0 commit comments