forked from iann0036/former2
-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (64 loc) · 3.11 KB
/
Copy pathrelease-please-branches.yml
File metadata and controls
70 lines (64 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
name: Create Releases From Branches
on:
push:
branches:
# See https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
- releases/v[0-9]+
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]${GITHUB_REF#refs/heads/}"
id: extract_branch
- uses: GoogleCloudPlatform/release-please-action@v3.4.0
id: release
with:
release-type: simple
default-branch: ${{ steps.extract_branch.outputs.branch }}
token: "${{ secrets.ACTIONS_TOKEN }}"
- uses: actions/checkout@v2
with:
fetch-depth: '0'
- name: Tag major and patch versions
if: ${{ steps.release.outputs.release_created }}
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
git remote add gh-token "https://${{ secrets.ACTIONS_TOKEN}}@github.com/google-github-actions/release-please-action.git"
git tag -d v${{ steps.release.outputs.major }} || true
git tag -d v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} || true
git push origin :v${{ steps.release.outputs.major }} || true
git push origin :v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} || true
git tag -a v${{ steps.release.outputs.major }} -m "Release v${{ steps.release.outputs.major }}"
git tag -a v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} -m "Release v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}"
git push origin v${{ steps.release.outputs.major }}
git push origin v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}
- name: Recreate latest tags for release ordering
if: ${{ steps.release.outputs.release_created }}
id: recreate-latest-tags
run: |
git fetch -avtf
LATEST="$(git tag -l|tail -1)"
LATEST_MAJOR="$(git tag -l|tail -1|awk -F"." '{print $1}')"
LATEST_MINOR="$(git tag -l|tail -1|awk -F"." '{print $1"."$2}')"
git checkout main
git tag -d "${LATEST}"
git tag -d "${LATEST_MAJOR}"
git tag -d "${LATEST_MINOR}"
git push origin :"${LATEST}"
git push origin :"${LATEST_MAJOR}"
git push origin :"${LATEST_MINOR}"
git tag -a "${LATEST}" -m "Release ${LATEST}"
git tag -a "${LATEST_MAJOR}" -m "Release ${LATEST_MAJOR}"
git tag -a "${LATEST_MINOR}" -m "Release ${LATEST_MINOR}"
git push origin "${LATEST}"
git push origin "${LATEST_MAJOR}"
git push origin "${LATEST_MINOR}"
echo "::set-output name=LATEST_RELEASE::${LATEST}"
- name: Publish release on GitHub
if: ${{ steps.release.outputs.release_created }}
uses: test-room-7/action-publish-release-drafts@v0
with:
tag-name: ${{ steps.recreate-latest-tags.outputs.LATEST_RELEASE }}