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
822jobs :
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