@@ -2,8 +2,8 @@ name: Release
22
33on :
44 push :
5- tags :
6- - " v*.*.* " # Run workflow on version tags, e.g. v1.0.0.
5+ branches :
6+ - main
77
88jobs :
99 release :
@@ -13,19 +13,14 @@ jobs:
1313 - uses : actions/checkout@v2
1414
1515 - name : Setup Node.js environment
16- uses : actions/setup-node@v2.1.2
16+ uses : actions/setup-node@v2
1717 with :
18- node-version : " 14.x"
19-
20- - name : Setup Go environment
21- uses : actions/setup-go@v2
22- with :
23- go-version : " 1.15"
18+ node-version : " 14.17"
2419
2520 - name : Get yarn cache directory path
2621 id : yarn-cache-dir-path
2722 run : echo "::set-output name=dir::$(yarn cache dir)"
28-
23+
2924 - name : Cache yarn cache
3025 uses : actions/cache@v2
3126 id : cache-yarn-cache
3429 key : ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
3530 restore-keys : |
3631 ${{ runner.os }}-yarn-
37-
32+
3833 - name : Cache node_modules
3934 id : cache-node-modules
4035 uses : actions/cache@v2
@@ -44,41 +39,51 @@ jobs:
4439 restore-keys : |
4540 ${{ runner.os }}-${{ matrix.node-version }}-nodemodules-
4641
47- - name : Install dependencies
48- run : yarn install --frozen-lockfile;
49- if : |
50- steps.cache-yarn-cache.outputs.cache-hit != 'true' ||
51- steps.cache-node-modules.outputs.cache-hit != 'true'
52-
53- - name : Build and test frontend
42+ - name : Build plugin
5443 run : yarn build
5544
56- - name : Check for backend
57- id : check-for-backend
45+ - name : Sign plugin
5846 run : |
59- if [ -f "Magefile.go" ]
60- then
61- echo "::set-output name=has-backend::true"
62- fi
47+ # We only have a single dependency, grafana-toolkit
48+ # So we install next to where it's needed
49+ yarn
50+ yarn sign
51+ env :
52+ GRAFANA_API_KEY : ${{ secrets.GRAFANA_API_KEY }} # Requires a Grafana API key from Grafana.com.
6353
64- - name : Test backend
65- if : steps.check-for-backend.outputs.has-backend == 'true'
66- uses : magefile/mage-action@v1
54+ # We reuse the same tests from the other repo, after all, why not?
55+ # TODO: run other tests that are valid here
56+ # eg: checking README etc
57+ - name : Run grafana server
58+ run : docker-compose -f pyroscope/grafana-plugin/datasource/docker-compose.yml up -d
59+ - name : Run tests
60+ run : yarn --cwd pyroscope cy:datasource:ci
61+ env :
62+ CYPRESS_VIDEO : true
63+ CYPRESS_COMPARE_SNAPSHOTS : true
64+ - uses : actions/upload-artifact@v2
65+ if : always()
66+ with :
67+ name : cypress-screenshots
68+ path : pyroscope/cypress/screenshots
69+ - uses : actions/upload-artifact@v2
70+ if : always()
6771 with :
68- version : latest
69- args : coverage
72+ name : cypress-videos
73+ path : pyroscope/cypress/videos
74+ - uses : actions/upload-artifact@v2
75+ if : always()
76+ with :
77+ name : cypress-snapshots
78+ # TODO: scope to only store screenshots that refer to grafana
79+ path : pyroscope/cypress/snapshots
7080
71- - name : Build backend
81+ # Setup the go environment, since the grafana plugin linter isn't distributed as a binary
82+ - name : Setup Go environment
7283 if : steps.check-for-backend.outputs.has-backend == 'true'
73- uses : magefile/mage-action@v1
84+ uses : actions/setup-go@v2
7485 with :
75- version : latest
76- args : buildAll
77-
78- - name : Sign plugin
79- run : yarn sign
80- env :
81- GRAFANA_API_KEY : ${{ secrets.GRAFANA_API_KEY }} # Requires a Grafana API key from Grafana.com.
86+ go-version : " 1.16"
8287
8388 - name : Get plugin metadata
8489 id : metadata
@@ -99,15 +104,6 @@ jobs:
99104
100105 echo ::set-output name=github-tag::${GITHUB_REF#refs/*/}
101106
102- - name : Read changelog
103- id : changelog
104- run : |
105- awk '/^## / {s++} s == 1 {print}' CHANGELOG.md > release_notes.md
106- echo "::set-output name=path::release_notes.md"
107-
108- - name : Check package version
109- run : if [ "v${{ steps.metadata.outputs.plugin-version }}" != "${{ steps.metadata.outputs.github-tag }}" ]; then printf "\033[0;31mPlugin version doesn't match tag name\033[0m\n"; exit 1; fi
110-
111107 - name : Package plugin
112108 id : package-plugin
113109 run : |
@@ -125,15 +121,37 @@ jobs:
125121 go install
126122 popd
127123 plugincheck2 -config lint.config.yaml ${{ steps.metadata.outputs.archive }}
124+ # until here it's pretty much the same as ci.yml
125+ # TODO: share the code somehow
126+
127+ # #########################
128+ # Release Specific Stuff #
129+ # #########################
130+ - name : Read changelog
131+ id : changelog
132+ run : |
133+ awk '/^## / {s++} s == 1 {print}' CHANGELOG.md > release_notes.md
134+ echo "::set-output name=path::release_notes.md"
128135
136+ - name : Create tag
137+ uses : actions/github-script@v5
138+ with :
139+ script : |
140+ github.rest.git.createRef({
141+ owner: context.repo.owner,
142+ repo: context.repo.repo,
143+ ref: 'refs/tags/v${{ steps.metadata.outputs.plugin-version }}',
144+ sha: context.sha
145+ })
146+
129147 - name : Create release
130148 id : create_release
131149 uses : actions/create-release@v1
132150 env :
133151 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
134152 with :
135- tag_name : ${{ github.ref }}
136- release_name : Release ${{ github.ref }}
153+ tag_name : ' v ${{ steps.metadata.outputs.plugin-version }}'
154+ release_name : Release ${{ steps.metadata.outputs.plugin-version }}
137155 body_path : ${{ steps.changelog.outputs.path }}
138156 draft : true
139157
@@ -161,6 +179,5 @@ jobs:
161179
162180 - name : Publish to Grafana.com
163181 run : |
164- echo A draft release has been created for your plugin. Please review and publish it. Then submit your plugin to grafana.com/plugins by opening a PR to https://github.com/grafana/grafana-plugin-repository with the following entry:
165- echo
166- echo '{ "id": "${{ steps.metadata.outputs.plugin-id }}", "type": "${{ steps.metadata.outputs.plugin-type }}", "url": "https://github.com/${{ github.repository }}", "versions": [ { "version": "${{ steps.metadata.outputs.plugin-version }}", "commit": "${{ github.sha }}", "url": "https://github.com/${{ github.repository }}", "download": { "any": { "url": "https://github.com/${{ github.repository }}/releases/download/v${{ steps.metadata.outputs.plugin-version }}/${{ steps.metadata.outputs.archive }}", "md5": "${{ steps.package-plugin.outputs.checksum }}" } } } ] }' | jq .
182+ echo "A draft release has been created for your plugin. Please review and publish it."
183+ echo "To publish a new version, follow https://github.com/grafana/grafana-plugin-repository#maintain-your-plugin"
0 commit comments