-
Notifications
You must be signed in to change notification settings - Fork 3
209 lines (165 loc) · 6.87 KB
/
Copy pathbuild-pre-release.yaml
File metadata and controls
209 lines (165 loc) · 6.87 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
name: build-pre-release
on:
# Runs daily at UTC midnight to minimize risk of overstepping
# manual builds of same date.
schedule:
- cron: "0 0 * * *"
# Allow manual activations.
workflow_dispatch:
permissions:
# Allow release creation
contents: write
env:
# prevents warnings in the vscode editor.
RELEASE_TAG: ""
PACKAGE_TAG: ""
VSCODE_EXTENSION_VERSION: ""
APIO_CLI_RELEASE_REPO: ""
APIO_CLI_RELEASE_TAG: ""
jobs:
# ----- Parameters collection job
build-pre-release:
runs-on: ubuntu-latest
steps:
- name: Checkout this repo
uses: actions/checkout@v4
- name: List repo files
run: |
ls -al
- name: Get release and package tags
uses: fpgawars/apio-workflows/.github/actions/get-release-and-package-tags@main
with:
release-tag-var: RELEASE_TAG
package-tag-var: PACKAGE_TAG
- name: Determine package file name
run: |
package_name="apio-vscode-${PACKAGE_TAG}.vsix"
echo "PACKAGE_NAME=$package_name"
echo "PACKAGE_NAME=$package_name" >> $GITHUB_ENV
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version-file: "package.json" # Detects from engines.node
- name: Verify npx
run: npx --version
- name: List repo files
run: |
ls -al
- name: Extract values and set environment variables
run: |
const workspace = process.env.GITHUB_WORKSPACE;
const fs = require('fs');
const path = require('path');
const constants = require(path.join(workspace, 'src', 'constants.js'));
const pkg = require(path.join(workspace, 'package.json'));
const envPath = process.env.GITHUB_ENV;
console.log(`VSCODE_EXTENSION_VERSION=${pkg.version}`)
fs.appendFileSync(envPath, `VSCODE_EXTENSION_VERSION=${pkg.version}\n`);
console.log(`APIO_CLI_RELEASE_REPO=${constants.APIO_CLI_RELEASE_REPO}`)
fs.appendFileSync(envPath, `APIO_CLI_RELEASE_REPO=${constants.APIO_CLI_RELEASE_REPO}\n`);
console.log(`APIO_CLI_RELEASE_TAG=${constants.APIO_CLI_RELEASE_TAG}`)
fs.appendFileSync(envPath, `APIO_CLI_RELEASE_TAG=${constants.APIO_CLI_RELEASE_TAG}\n`);
shell: node {0}
# Create the build info file that we will include in the package.
- name: Create build info
run: |
# Generate build-info.json
cat > build-info.json <<EOF
{
"package-name": "apio-ide",
"description" : "Apio extension for Visual Studio Code",
"source-repo": "${{github.repository}}",
"source-sha": "${{ github.sha }}",
"source-branch": "${{ github.ref_name }}",
"apio-ide-version": "$VSCODE_EXTENSION_VERSION",
"apio-ide-release-tag": "${RELEASE_TAG}",
"apio-cli-release-repo": "$APIO_CLI_RELEASE_REPO",
"apio-cli-release-tag" : "$APIO_CLI_RELEASE_TAG",
"build-time": "$(date +'%Y-%m-%d %H:%M:%S %Z')",
"builder-workflow": "${{ github.workflow }}",
"workflow-run-id": "${{github.run_id}}",
"workflow-run-number": "${{github.run_number}}"
}
EOF
cat -n build-info.json
- name: Format build info json file in-place
uses: fpgawars/apio-workflows/.github/actions/format-json-file@main
with:
json-file: build-info.json
- name: Build the .vsix file
run: |
./scripts/build.sh
- name: Rename package file
run: |
mv apio*.vsix $PACKAGE_NAME
ls -al
- name: Show packaged files
run: |
unzip -l $PACKAGE_NAME
- name: Convert json build info to text
uses: fpgawars/apio-workflows/.github/actions/json-to-text@main
with:
input-json: build-info.json
output-text: build-info.txt
# Summary for the workflow run page.
- name: Prepare workflow run summary
run: |
cat > RUN-SUMMARY.txt <<EOF
Build info:
\`\`\`
$(cat build-info.txt)
\`\`\`
- [Apio IDE cutoff commit](https://github.com/${{ github.repository }}/commit/${{ github.sha }})
- [Linked Apio CLI release](https://github.com/${APIO_CLI_RELEASE_REPO}/releases/tag/${APIO_CLI_RELEASE_TAG}) \
(Must exist for this Apio IDE release to work)
- [Generated Apio IDE pre-release](https://github.com/${{ github.repository }}/releases/tag/${RELEASE_TAG})
EOF
ls -al
cat -n RUN-SUMMARY.txt
- name: Post workflow run summary
run: |
cat RUN-SUMMARY.txt >> $GITHUB_STEP_SUMMARY
# Add notes for the release page.
- name: Create the release text
run: |
cat > RELEASE-BODY.txt <<EOF
> ### Pre-release note
>
> This daily release was created as a pre-release and
> will be deleted after 5 days unless if it's marked as a stable release. To make
> this a stable release, do the following:
> * Open the release for editing.
> * Turn off the \`Set as a pre-release\` checkbox below.
> * (optional) Turn on the \`Set as the latest release\` checkbox.
> * Remove this pre-release note.
> * (optional) Add release notes.
> * Click \`Update Release\` button to save your changes.
### Dependency note
This Apio IDE release is hard coded to fetch the Apio binary from \
[Apio CLI release $APIO_CLI_RELEASE_TAG](https://github.com/$APIO_CLI_RELEASE_REPO/releases/tag/$APIO_CLI_RELEASE_TAG) \
which must exist for this VS Code extension to be functional.
### Installation
This VS Code extension is typically installed directly from the VS Code Marketplace \
[where it's published](https://marketplace.visualstudio.com/items?itemName=fpgawars.apio). \
To side load the .vsix file from here use the VS Code \
\`Install from VSIX\` command in the extensions menu.
### Build info
\`\`\`
$(cat build-info.txt)
\`\`\`
EOF
cat -n RELEASE-BODY.txt
- name: Cleanup old pre-releases
uses: fpgawars/apio-workflows/.github/actions/cleanup-old-prereleases@main
- name: Ensure no conflicting release
uses: fpgawars/apio-workflows/.github/actions/ensure-no-conflicting-release@main
with:
release-tag: ${{ env.RELEASE_TAG }}
- name: Create GitHub pre-release
uses: fpgawars/apio-workflows/.github/actions/create-pre-release@main
with:
release_tag: ${{ env.RELEASE_TAG }}
body_path: RELEASE-BODY.txt
# We intensionally list explicitly all the expected files.
files: |
apio-vscode-${{env.PACKAGE_TAG}}.vsix