-
Notifications
You must be signed in to change notification settings - Fork 0
116 lines (107 loc) · 3.78 KB
/
build-deploy.yml
File metadata and controls
116 lines (107 loc) · 3.78 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
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
name: Build & Deploy
run-name: Initiated by ${{ github.actor }}
# Run on main branch with tag v*.*.*
on:
workflow_dispatch:
inputs:
tag:
description: 'Tag to deploy'
required: true
default: 'v0.0.0'
description:
description: 'Description of the release'
required: true
default: 'Release v0.0.0'
jobs:
check:
runs-on: ubuntu-latest
outputs:
tag_exists: ${{ steps.create_job_outputs.outputs.tag_exists }}
steps:
- name: Check if tag already exists
id: check_tag_exists
uses: mukunku/tag-exists-action@v1.2.0
with:
tag: ${{ github.event.inputs.tag }}
# Create job outputs
- name: Create job outputs
id: create_job_outputs
run: |
echo "tag_exists=${{ steps.check_tag_exists.outputs.exists }}" >> $GITHUB_OUTPUT
build:
needs: check
if: ${{ needs.check.outputs.tag_exists == 'false' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16.19.0
# Update package.json with the new version number
- name: Update package.json
uses:
actions/github-script@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const packageJson = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
packageJson.version = '${{ github.event.inputs.tag }}';
fs.writeFileSync('./package.json', JSON.stringify(packageJson, null, 2));
# Push the change to the main branch
- name: Push changes to main
run: |
git config --local user.email "damandhillon08@gmail.com"
git config --local user.name "Daman Dhillon"
git add package.json
git commit -m "Update package.json with version ${{ github.event.inputs.tag }}"
git push
# Install dependencies
- run: npm install
- run: npm install -g vsce
# Build the extension
- run: vsce package
env:
COMMIT_GRAPHQL_API_URL : https://api.commit.dev/graphql
COMMIT_API_BASE_URL : https://api.commit.dev
COMMIT_APP_BASE_URL : https://app.commit.dev
COMMIT_AUTH0_DOMAIN : https://commitdev.auth0.com
COMMIT_CLIENT_ID : ${{ secrets.COMMIT_CLIENT_ID_STAGING }}
# Upload the VSIX file as an artifact with version number
- uses: actions/upload-artifact@v3
with:
name: commit-extension-${{ github.event.inputs.tag }}
path: ./*.vsix
# Create a release with the version number
deploy:
needs: build
runs-on: ubuntu-latest
steps:
# Download the VSIX file from the artifact
- uses: actions/download-artifact@v3
with:
name: commit-extension-${{ github.event.inputs.tag }}
path: ./
# Upload the VSIX file to the Github release
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event.inputs.tag }}
release_name: ${{ github.event.inputs.tag }}
body: |
${{ github.event.inputs.description }}
draft: false
prerelease: false
# Upload the VSIX file to the Github release
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./commit-extension-${{ github.event.inputs.tag }}.vsix
asset_name: commit-extension-${{ github.event.inputs.tag }}.vsix
asset_content_type: application/zip