forked from devcontainers/cli
-
Notifications
You must be signed in to change notification settings - Fork 1
126 lines (114 loc) · 4.17 KB
/
publish-dev-containers.yml
File metadata and controls
126 lines (114 loc) · 4.17 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
name: Publish @devcontainers/cli
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
npm-publish:
type: boolean
default: false
description: "Publish to NPM"
make-release:
type: boolean
default: false
description: "Make GitHub Release"
draft-release:
type: boolean
default: false
description: "Make GitHub Draft Release"
jobs:
main:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Setup Node.js
if: github.repository == 'devcontainers/cli' && (github.event_name != 'workflow_dispatch' || inputs.npm-publish == true)
uses: actions/setup-node@v3
with:
node-version: '14.x'
registry-url: 'https://registry.npmjs.org'
scope: '@devcontainers'
- name: Verify Versions
if: github.repository == 'devcontainers/cli' && (github.event_name != 'workflow_dispatch' || inputs.npm-publish == true)
shell: bash
run: |
node -e "
const packageRef = 'refs/tags/v' + require('./package.json').version;
const githubRef = '${{ github.ref }}';
if (githubRef.includes(packageRef)) {
console.log('::error::' + 'Version Mismatch.', packageRef, githubRef);
throw Error('Version Mismatch');
}
"
- name: Download Artifacts
uses: dawidd6/action-download-artifact@v2
with:
commit: ${{ github.sha }}
workflow: dev-containers.yml
workflow_conclusion: success
- name: Env
shell: bash
run: |
VER=$(cat package.json | jq -r '.version')
echo "VER=${VER}" >> $GITHUB_ENV;
echo "SLUG=${VER}-${GITHUB_SHA:0:8}" >> $GITHUB_ENV;
TAG="${{ github.ref }}";
if [[ "${{ github.event_name }}" != 'workflow_dispatch' ]]; then
TAG="${TAG#refs/tags/}";
else
TAG="$(git describe --abbrev=0 --tags)";
fi
echo "TAG=${TAG}" >> $GITHUB_ENV;
if [[ "$TAG" =~ "-pre-release" ]]; then
echo "PRERELEASE=true" >> $GITHUB_ENV;
else
echo "PRERELEASE=false" >> $GITHUB_ENV;
fi
find . -type f \( \
-name "devcontainer-linux-x64" \
-or -name "devcontainer-linux-arm64" \
-or -name "devcontainer-macos-x64" \
-or -name "devcontainer-macos-arm64" \
-or -name "devcontainer-win-x64.exe" \
-or -name "devcontainer-win-arm64.exe" \
-or -name "devcontainers-cli-0.29.0.tgz" \
\) -exec mv {} . \;
- name: Publish npm package
if: github.repository == 'devcontainers/cli' && (github.event_name != 'workflow_dispatch' || inputs.npm-publish == true)
run: npm publish devcontainers-cli-${VER}.tgz --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Upload release smoketest artifacts
if: github.event_name == 'workflow_dispatch' && inputs.make-release != true && inputs.draft-release != true
uses: actions/upload-artifact@v3
with:
name: devcontainers-cli-${{ env.SLUG }}
path: |
devcontainer-linux-x64
devcontainer-linux-arm64
devcontainer-macos-x64
devcontainer-macos-arm64
devcontainer-win-x64.exe
devcontainer-win-arm64.exe
devcontainers-cli-${{ env.VER }}.tgz
- name: Create GitHub release
if: github.event_name != 'workflow_dispatch' || inputs.make-release == true || inputs.draft-release == true
uses: softprops/action-gh-release@v1
with:
body_path: CHANGELOG.md
tag_name: ${{ env.TAG }}
repository: ${{ github.repository }}
prerelease: ${{ env.PRERELEASE == 'true' }}
draft: ${{ github.event_name == 'workflow_dispatch' && inputs.draft-release == true }}
files: |
devcontainer-linux-x64
devcontainer-linux-arm64
devcontainer-macos-x64
devcontainer-macos-arm64
devcontainer-win-x64.exe
devcontainer-win-arm64.exe
devcontainers-cli-${{ env.VER }}.tgz