|
| 1 | +name: tag-git |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + ref: |
| 7 | + description: 'Optionally override which branch to build' |
| 8 | + required: false |
| 9 | + default: main |
| 10 | + repository: |
| 11 | + description: 'Optionally override from where to fetch the specified ref' |
| 12 | + required: false |
| 13 | + default: git-for-windows/git |
| 14 | + |
| 15 | +env: |
| 16 | + GPG_OPTIONS: "--batch --yes --no-tty --list-options no-show-photos --verify-options no-show-photos --pinentry-mode loopback" |
| 17 | + HOME: "${{github.workspace}}\\home" |
| 18 | + USERPROFILE: "${{github.workspace}}\\home" |
| 19 | + REPOSITORY: "${{github.event.inputs.repository}}" |
| 20 | + REF: "${{github.event.inputs.ref}}" |
| 21 | + NODEJS_VERSION: 16 |
| 22 | + |
| 23 | +jobs: |
| 24 | + tag-git: |
| 25 | + runs-on: ubuntu-latest |
| 26 | + steps: |
| 27 | + - name: Configure user |
| 28 | + run: |
| 29 | + USER_NAME="${{github.actor}}" && |
| 30 | + USER_EMAIL="${{github.actor}}@users.noreply.github.com" && |
| 31 | + mkdir "$HOME" && |
| 32 | + git config --global user.name "$USER_NAME" && |
| 33 | + git config --global user.email "$USER_EMAIL" && |
| 34 | + echo "PACKAGER=$USER_NAME <$USER_EMAIL>" >> $GITHUB_ENV |
| 35 | + - name: Clone build-extra |
| 36 | + run: git clone --single-branch -b main https://github.com/git-for-windows/build-extra $RUNNER_TEMP/build-extra |
| 37 | + - name: Prepare home directory for GPG signing |
| 38 | + if: env.GPGKEY != '' |
| 39 | + run: | |
| 40 | + echo '${{secrets.PRIVGPGKEY}}' | tr % '\n' | gpg $GPG_OPTIONS --import && |
| 41 | + mkdir -p home && |
| 42 | + git config --global gpg.program "$RUNNER_TEMP/build-extra/gnupg-with-gpgkey.sh" && |
| 43 | + info="$(gpg --list-keys --with-colons "${GPGKEY%% *}" | cut -d : -f 1,10 | sed -n '/^uid/{s|uid:||p;q}')" && |
| 44 | + git config --global user.name "${info% <*}" && |
| 45 | + git config --global user.email "<${info#*<}" |
| 46 | + env: |
| 47 | + GPGKEY: ${{secrets.GPGKEY}} |
| 48 | + - uses: actions/setup-node@v3 |
| 49 | + with: |
| 50 | + node-version: ${{env.NODEJS_VERSION}} |
| 51 | + - name: Generate bundle artifacts |
| 52 | + env: |
| 53 | + GPGKEY: ${{secrets.GPGKEY}} |
| 54 | + run: | |
| 55 | + mkdir -p bundle-artifacts && |
| 56 | + git -c init.defaultBranch=main init --bare && |
| 57 | + git remote add -f origin https://github.com/git-for-windows/git && |
| 58 | + git fetch "https://github.com/$REPOSITORY" "$REF:$REF" && |
| 59 | + tag_name="$(git describe --match 'v[0-9]*' FETCH_HEAD)" && |
| 60 | + echo "prerelease-${tag_name#v}" >bundle-artifacts/ver && |
| 61 | + echo "${tag_name#v}" >bundle-artifacts/display_version && |
| 62 | + echo "$tag_name" >bundle-artifacts/next_version && |
| 63 | + git tag $(test -z "$GPGKEY" || echo " -s") -m "Snapshot build" "$tag_name" FETCH_HEAD && |
| 64 | + git bundle create bundle-artifacts/git.bundle origin/main.."$tag_name" && |
| 65 | + release_note=$(git show -s --pretty='tformat:%h (%s, %ad)' --date=short FETCH_HEAD) && |
| 66 | + cd $RUNNER_TEMP/build-extra && |
| 67 | + node ./add-release-note.js --commit feature "Snapshot of $release_note" && |
| 68 | + git bundle create "$GITHUB_WORKSPACE/bundle-artifacts/build-extra.bundle" origin/main..main |
| 69 | + - name: 'Publish Pipeline Artifact: bundle-artifacts' |
| 70 | + uses: actions/upload-artifact@v3 |
| 71 | + with: |
| 72 | + name: bundle-artifacts |
| 73 | + path: ${{ github.workspace }}/bundle-artifacts |
0 commit comments