-
Notifications
You must be signed in to change notification settings - Fork 6
139 lines (113 loc) · 5.36 KB
/
release.yml
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: Release
on:
push:
branches: [ master ]
jobs:
release:
name: Release extension to Marketplace
runs-on: ubuntu-latest
if: contains(github.event.head_commit.message, 'release:trigger')
defaults:
run:
working-directory: ${{ github.workspace }}
steps:
- name: checkout repo
uses: actions/checkout@v4
- name: setup node
uses: actions/setup-node@v4
with:
node-version: 22
- name: clean install dependencies
run: npm ci
- name: fetch all history and tags for gitversion
run: git fetch --prune --unshallow
- name: install gitversion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '6.0.x'
- name: execute gitversion
id: gitversion-before
uses: gittools/actions/gitversion/[email protected]
- name: print gitversion before release
run: |
echo "Major: ${{ steps.gitversion-before.outputs.major }}"
echo "Minor: ${{ steps.gitversion-before.outputs.minor }}"
echo "Patch: ${{ steps.gitversion-before.outputs.patch }}"
echo "MajorMinorPatch: ${{ steps.gitversion-before.outputs.majorMinorPatch }}"
echo "SemVer: ${{ steps.gitversion-before.outputs.semVer }}"
- name: update version in package.json
run: |
sed -e '/"version"/s/: ".*"/: "${{ steps.gitversion-before.outputs.semVer }}"/' package.json | tee package.json.modified
mv package.json.modified package.json
- name: compile and create vsix
run: npm run package
- name: publish to marketplace
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
run: npm run deploy
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
- name: create a release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.gitversion-before.outputs.semVer }}
release_name: v${{ steps.gitversion-before.outputs.semVer }}
body: |
# ${{ steps.gitversion-before.outputs.semVer }} - ${{ steps.date.outputs.date }}
- name: upload release asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./plastic-scm-${{ steps.gitversion-before.outputs.semVer }}.vsix
asset_name: plastic-scm-${{ steps.gitversion-before.outputs.semVer }}.vsix
asset_content_type: application/zip
- name: fetch new tag for gitversion
run: git fetch
- name: bump version by using an empty commit
run: |
git config --global user.name 'Plastic SCM Releases'
git config --global user.email '[email protected]'
git commit --allow-empty -s -m 'Empty commit to bump version'
- name: execute gitversion again
id: gitversion-after
uses: gittools/actions/gitversion/[email protected]
- name: print gitversion after release
run: |
echo "Major: ${{ steps.gitversion-after.outputs.major }}"
echo "Minor: ${{ steps.gitversion-after.outputs.minor }}"
echo "Patch: ${{ steps.gitversion-after.outputs.patch }}"
echo "MajorMinorPatch: ${{ steps.gitversion-after.outputs.majorMinorPatch }}"
echo "SemVer: ${{ steps.gitversion-after.outputs.semVer }}"
- name: update new version in package.json
run: |
sed -e '/"version"/s/: ".*"/: "${{ steps.gitversion-after.outputs.semVer }}"/' package.json | tee package.json.modified
mv package.json.modified package.json
- name: create pull request
id: cpr
uses: peter-evans/create-pull-request@v7
with:
commit-message: '[create-pull-request] Bump version to ${{ steps.gitversion-after.outputs.semVer }}'
title: >
Bump version
from ${{ steps.gitversion-before.outputs.semVer }}
to ${{ steps.gitversion-after.outputs.semVer }}
body: |
Release `${{ steps.gitversion-before.outputs.semVer }}` was successful!
Let's make it official and update that version number.
Since this PR is triggered from inside a workflow, GitHub prevents it from
triggering other workflows (e.g. CI) to avoid recursive workflow runs.
[See more info here](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#triggering-new-workflows-using-a-personal-access-token).
As a workaround, checkout that PR branch and push an empty commit to it.
Automated changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action
labels: release, automated
branch: bump-version-${{ steps.gitversion-after.outputs.semVer }}
- name: print PR number
run: |
echo 'Created pull request #${{ steps.cpr.outputs.pull-request-number }}'