Skip to content

Commit a3f920b

Browse files
committed
CI release action must only publish one type of vsix
Publish either a pre-release or an ordinary one, depending on whether the release was tagged in the prerelease branch or the master branch.
1 parent 0171f83 commit a3f920b

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

.github/workflows/main.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ on:
1414
branches:
1515
- master
1616
release:
17-
branches:
18-
- master
1917
types:
2018
- released
2119
jobs:
@@ -25,9 +23,20 @@ jobs:
2523
strategy:
2624
matrix:
2725
os: [ubuntu-latest, windows-latest, macOS-latest]
26+
outputs:
27+
taggedbranch: ${{ steps.find-branch.outputs.taggedbranch }}
2828
steps:
2929
- uses: actions/checkout@v2
3030
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
31+
- name: Find which branch the release tag points at
32+
id: find-branch
33+
if: github.event_name == 'release' && runner.os == 'Linux'
34+
shell: bash
35+
run: |
36+
git fetch --depth=1 origin +refs/heads/*:refs/heads/*
37+
set -x
38+
TAGGEDBRANCH=$(git for-each-ref --points-at=${{github.sha}} --format='%(refname:lstrip=2)' refs/heads/)
39+
echo ::set-output name=taggedbranch::$TAGGEDBRANCH
3140
- name: Set an output
3241
id: set-version
3342
if: runner.os == 'Linux'
@@ -67,7 +76,7 @@ jobs:
6776
run: |
6877
npx vsce package -o ${{ steps.set-version.outputs.name }}.vsix
6978
- uses: actions/upload-artifact@v2
70-
if: runner.os == 'Linux'
79+
if: (runner.os == 'Linux') && (github.event_name != 'release')
7180
with:
7281
name: ${{ steps.set-version.outputs.name }}.vsix
7382
path: ${{ steps.set-version.outputs.name }}.vsix
@@ -122,9 +131,9 @@ jobs:
122131
asset_name: ${{ steps.set-version.outputs.name }}.vsix
123132
asset_content_type: application/zip
124133
publish:
125-
if: github.event_name == 'release'
126-
runs-on: ubuntu-latest
127134
needs: build
135+
if: github.event_name == 'release' && needs.build.outputs.taggedbranch == 'master'
136+
runs-on: ubuntu-latest
128137
steps:
129138
- uses: actions/checkout@v2
130139
with:

.github/workflows/prerelease.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ on:
1414
branches:
1515
- prerelease
1616
release:
17-
branches:
18-
- prerelease
1917
types:
2018
- released
2119
jobs:
@@ -25,9 +23,20 @@ jobs:
2523
strategy:
2624
matrix:
2725
os: [ubuntu-latest, windows-latest, macOS-latest]
26+
outputs:
27+
taggedbranch: ${{ steps.find-branch.outputs.taggedbranch }}
2828
steps:
2929
- uses: actions/checkout@v2
3030
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
31+
- name: Find which branch the release tag points at
32+
id: find-branch
33+
if: github.event_name == 'release' && runner.os == 'Linux'
34+
shell: bash
35+
run: |
36+
git fetch --depth=1 origin +refs/heads/*:refs/heads/*
37+
set -x
38+
TAGGEDBRANCH=$(git for-each-ref --points-at=${{github.sha}} --format='%(refname:lstrip=2)' refs/heads/)
39+
echo ::set-output name=taggedbranch::$TAGGEDBRANCH
3140
- name: Set an output
3241
id: set-version
3342
if: runner.os == 'Linux'
@@ -67,7 +76,7 @@ jobs:
6776
run: |
6877
npx vsce package --pre-release -o ${{ steps.set-version.outputs.name }}.vsix
6978
- uses: actions/upload-artifact@v2
70-
if: runner.os == 'Linux'
79+
if: (runner.os == 'Linux') && (github.event_name != 'release')
7180
with:
7281
name: ${{ steps.set-version.outputs.name }}.vsix
7382
path: ${{ steps.set-version.outputs.name }}.vsix
@@ -122,9 +131,9 @@ jobs:
122131
asset_name: ${{ steps.set-version.outputs.name }}.vsix
123132
asset_content_type: application/zip
124133
publish:
125-
if: github.event_name == 'release'
126-
runs-on: ubuntu-latest
127134
needs: build
135+
if: github.event_name == 'release' && needs.build.outputs.taggedbranch == 'prerelease'
136+
runs-on: ubuntu-latest
128137
steps:
129138
- uses: actions/checkout@v2
130139
with:

0 commit comments

Comments
 (0)