Skip to content

Commit b146bb6

Browse files
committed
publish github releases with artifacts
1 parent 2fb68ae commit b146bb6

3 files changed

Lines changed: 112 additions & 16 deletions

File tree

.github/workflows/build-chat.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111

1212
jobs:
1313
main:
14+
if: github.repository == 'devcontainers/cli'
1415
runs-on: ubuntu-latest
1516
steps:
1617
- name: Checkout Actions

.github/workflows/dev-containers.yml

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,41 @@ concurrency:
1313
cancel-in-progress: true
1414

1515
jobs:
16+
changed:
17+
name: Check for changed files
18+
runs-on: ubuntu-latest
19+
outputs:
20+
any_changed: ${{ steps.changes.outputs.any_changed }}
21+
any_deleted: ${{ steps.changes.outputs.any_deleted }}
22+
steps:
23+
- name: Checkout ${{ github.repository }}
24+
uses: actions/checkout@v3
25+
with:
26+
fetch-depth: 0
27+
persist-credentials: false
28+
- name: Check if source files changed
29+
id: changes
30+
uses: tj-actions/[email protected]
31+
with:
32+
files: |
33+
*.js
34+
*.json
35+
yarn.lock
36+
package.json
37+
.github/workflows/dev-containers.yml
38+
src/**
39+
build/**
40+
scripts/**
41+
- name: Report changes
42+
shell: bash
43+
run: |
44+
echo '${{ toJSON(steps.changes.outputs) }}'
45+
1646
cli:
1747
name: CLI
1848
runs-on: ${{ matrix.os }}-latest
1949
strategy:
20-
fail-fast: true
50+
fail-fast: false
2151
matrix:
2252
include:
2353
- { os: ubuntu, pkg: node, os-name: linux, node: 16 }
@@ -76,11 +106,12 @@ jobs:
76106
path: ${{ env.ARTIFACT_PATH }}
77107

78108
tests-matrix:
79-
needs: cli
80109
name: Test
110+
needs: [changed, cli]
111+
if: needs.changed.outputs.any_changed == 'true' || needs.changed.outputs.any_deleted == 'true'
81112
runs-on: ${{ matrix.os }}-latest
82113
strategy:
83-
fail-fast: true
114+
fail-fast: false
84115
matrix:
85116
os: [ubuntu]
86117
pkg: [node]

.github/workflows/publish-dev-containers.yml

Lines changed: 77 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@ on:
44
push:
55
tags:
66
- 'v*'
7+
workflow_dispatch:
8+
inputs:
9+
npm-publish:
10+
type: boolean
11+
default: false
12+
description: "Publish to NPM"
13+
make-release:
14+
type: boolean
15+
default: false
16+
description: "Make GitHub Release"
17+
draft-release:
18+
type: boolean
19+
default: false
20+
description: "Make GitHub Draft Release"
721

822
jobs:
923
main:
@@ -13,50 +27,100 @@ jobs:
1327
uses: actions/checkout@v3
1428
with:
1529
persist-credentials: false
30+
1631
- name: Setup Node.js
32+
if: github.repository == 'devcontainers/cli' && (github.event_name != 'workflow_dispatch' || inputs.npm-publish == true)
1733
uses: actions/setup-node@v3
1834
with:
1935
node-version: '14.x'
2036
registry-url: 'https://registry.npmjs.org'
2137
scope: '@devcontainers'
38+
2239
- name: Verify Versions
40+
if: github.repository == 'devcontainers/cli' && (github.event_name != 'workflow_dispatch' || inputs.npm-publish == true)
41+
shell: bash
2342
run: |
2443
node -e "
2544
const packageRef = 'refs/tags/v' + require('./package.json').version;
2645
const githubRef = '${{ github.ref }}';
27-
if (packageRef !== githubRef && packageRef + '-pre-release' != githubRef) {
46+
if (githubRef.includes(packageRef)) {
2847
console.log('::error::' + 'Version Mismatch.', packageRef, githubRef);
2948
throw Error('Version Mismatch');
3049
}
3150
"
32-
- name: Env
33-
run: |
34-
TAG="${{ github.ref }}";
35-
TAG="${TAG#refs/tags/}";
36-
echo "TAG=${TAG}" >> $GITHUB_ENV;
37-
VER=$(cat package.json | jq -r '.version')
38-
echo "VER=${VER}" >> $GITHUB_ENV;
51+
3952
- name: Download Artifacts
40-
uses: dawidd6/action-download-artifact@6f8f427fb41886a66b82ea11a5a15d1454c79415
53+
uses: dawidd6/action-download-artifact@v2
4154
with:
55+
commit: ${{ github.sha }}
4256
workflow: dev-containers.yml
4357
workflow_conclusion: success
44-
commit: ${{ github.sha }}
45-
- name: Publish package
58+
59+
- name: Env
60+
shell: bash
61+
run: |
62+
VER=$(cat package.json | jq -r '.version')
63+
echo "VER=${VER}" >> $GITHUB_ENV;
64+
echo "SLUG=${VER}-${GITHUB_SHA:0:8}" >> $GITHUB_ENV;
65+
66+
TAG="${{ github.ref }}";
67+
if [[ "${{ github.event_name }}" != 'workflow_dispatch' ]]; then
68+
TAG="${TAG#refs/tags/}";
69+
else
70+
TAG="$(git describe --abbrev=0 --tags)";
71+
fi
72+
echo "TAG=${TAG}" >> $GITHUB_ENV;
73+
74+
if [[ "$TAG" =~ "-pre-release" ]]; then
75+
echo "PRERELEASE=true" >> $GITHUB_ENV;
76+
else
77+
echo "PRERELEASE=false" >> $GITHUB_ENV;
78+
fi
79+
80+
find . -type f \( \
81+
-name "devcontainer-linux-x64" \
82+
-or -name "devcontainer-linux-arm64" \
83+
-or -name "devcontainer-macos-x64" \
84+
-or -name "devcontainer-macos-arm64" \
85+
-or -name "devcontainer-win-x64.exe" \
86+
-or -name "devcontainer-win-arm64.exe" \
87+
-or -name "devcontainers-cli-0.29.0.tgz" \
88+
\) -exec mv {} . \;
89+
90+
- name: Publish npm package
91+
if: github.repository == 'devcontainers/cli' && (github.event_name != 'workflow_dispatch' || inputs.npm-publish == true)
4692
run: npm publish devcontainers-cli-${VER}.tgz --access public
4793
env:
4894
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
95+
96+
- name: Upload release smoketest artifacts
97+
if: github.event_name == 'workflow_dispatch' && inputs.make-release != true && inputs.draft-release != true
98+
uses: actions/upload-artifact@v3
99+
with:
100+
name: devcontainers-cli-${{ env.SLUG }}
101+
path: |
102+
devcontainer-linux-x64
103+
devcontainer-linux-arm64
104+
devcontainer-macos-x64
105+
devcontainer-macos-arm64
106+
devcontainer-win-x64.exe
107+
devcontainer-win-arm64.exe
108+
devcontainers-cli-${{ env.VER }}.tgz
109+
49110
- name: Create GitHub release
111+
if: github.event_name != 'workflow_dispatch' || inputs.make-release == true || inputs.draft-release == true
50112
uses: softprops/action-gh-release@v1
51113
with:
52-
body_path: CHANGELOG.txt
114+
body_path: CHANGELOG.md
53115
tag_name: ${{ env.TAG }}
54116
repository: ${{ github.repository }}
117+
prerelease: ${{ env.PRERELEASE == 'true' }}
118+
draft: ${{ github.event_name == 'workflow_dispatch' && inputs.draft-release == true }}
55119
files: |
56-
devcontainers-cli-${{ env.VER }}.tgz
57120
devcontainer-linux-x64
58121
devcontainer-linux-arm64
59122
devcontainer-macos-x64
60123
devcontainer-macos-arm64
61124
devcontainer-win-x64.exe
62125
devcontainer-win-arm64.exe
126+
devcontainers-cli-${{ env.VER }}.tgz

0 commit comments

Comments
 (0)