|
9 | 9 | required: true |
10 | 10 | default: 'v0.0.0' |
11 | 11 | jobs: |
| 12 | + check: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - name: Check if tag already exists |
| 16 | + id: check_tag_exists |
| 17 | + |
| 18 | + with: |
| 19 | + tag: ${{ github.event.inputs.tag }} |
| 20 | + # Create job outputs |
| 21 | + - name: Create job outputs |
| 22 | + id: create_job_outputs |
| 23 | + run: | |
| 24 | + echo "tag_exists=${{ steps.check_tag_exists.outputs.exists }}" >> $GITHUB_OUTPUTS |
12 | 25 | build: |
| 26 | + needs: check |
| 27 | + if: ${{ needs.check.outputs.tag_exists == 'false' }} |
13 | 28 | runs-on: ubuntu-latest |
14 | 29 | steps: |
15 | 30 | - uses: actions/checkout@v2 |
@@ -49,29 +64,16 @@ jobs: |
49 | 64 | path: ./ |
50 | 65 |
|
51 | 66 | # Check if the tag already exists |
52 | | - - name: Check if release exists |
53 | | - id: check_release |
54 | | - uses: actions/github-script@v5 |
| 67 | + - name: Check if tag already exists |
| 68 | + id: check_tag_exists |
| 69 | + |
55 | 70 | with: |
56 | | - github-token: ${{ secrets.GITHUB_TOKEN }} |
57 | | - script: | |
58 | | - const release = await github.repos.getReleaseByTag({ |
59 | | - owner: context.repo.owner, |
60 | | - repo: context.repo.repo, |
61 | | - tag: context.ref.replace('refs/tags/', '') |
62 | | - }).catch(err => { |
63 | | - if (err.status === 404) { |
64 | | - return null; |
65 | | - } |
66 | | - throw err; |
67 | | - }); |
68 | | - console.log('Release exists: ' + (release !== null)); |
69 | | - return release ? { exists: 'true' } : { exists: 'false' }; |
| 71 | + tag: ${{ github.event.inputs.tag }} |
70 | 72 |
|
71 | 73 | # Upload the VSIX file to the Github release |
72 | 74 | - name: Create Release |
73 | 75 | id: create_release |
74 | | - if: ${{ steps.check_release.outputs.exists == 'false' }} |
| 76 | + if: ${{ steps.check_tag_exists.outputs.exists == 'false' }} |
75 | 77 | uses: actions/create-release@latest |
76 | 78 | env: |
77 | 79 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
|
83 | 85 | draft: false |
84 | 86 | prerelease: false |
85 | 87 | - name: Upload Release Asset |
86 | | - if: ${{ steps.check_release.outputs.exists == 'false' }} |
| 88 | + if: ${{ steps.check_tag_exists.outputs.exists == 'false' }} |
87 | 89 | uses: actions/upload-release-asset@v1 |
88 | 90 | env: |
89 | 91 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
|
0 commit comments