-
Notifications
You must be signed in to change notification settings - Fork 251
112 lines (92 loc) · 3.57 KB
/
release-publish.yml
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
name: Publish release
on:
release:
types: [published]
jobs:
publish:
runs-on: ubuntu-latest
env:
DOCKERFILE: Dockerfile
IMAGENAME: mermaid-cli
DOCKER_IO_REPOSITORY: minlag/mermaid-cli
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: fregante/setup-git-user@v2
- uses: actions/setup-node@v4
with:
node-version: 14
cache: npm
registry-url: https://registry.npmjs.org/
- name: Install Yarn
run: npm i yarn --global
- name: Build the package
# throws an error if yarn.lock is out-of-date
# `yarn install` automatically builds the package
run: yarn install --frozen-lockfile
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0.10.2
with:
versionSpec: "5.x"
- name: Use GitVersion
id: gitversion # step id used as reference for output values
uses: gittools/actions/gitversion/execute@v0.10.2
- name: Get release version
run: echo "RELEASE_VERSION=${{ steps.gitversion.outputs.semVer }}" >> $GITHUB_ENV
- name: Prepare release
run: npm version --no-git-tag-version --allow-same-version ${{env.RELEASE_VERSION}}
- name: Convert repository name to lower case
run: echo "GITHUB_REPOSITORY_LOWER_CASE=$(echo $GITHUB_REPOSITORY | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Publish to npmjs
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- name: The job has failed
if: ${{ failure() }}
uses: actions/upload-artifact@v4.3.0
with:
name: npm-logs
path: /home/runner/.npm/_logs
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and Push Image(s)
uses: docker/build-push-action@v5
with:
context: .
file: ${{env.DOCKERFILE}}
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{env.DOCKER_IO_REPOSITORY}}:latest
${{env.DOCKER_IO_REPOSITORY}}:${{env.RELEASE_VERSION}}
ghcr.io/${{env.GITHUB_REPOSITORY_LOWER_CASE}}/${{env.IMAGENAME}}:latest
ghcr.io/${{env.GITHUB_REPOSITORY_LOWER_CASE}}/${{env.IMAGENAME}}:${{env.RELEASE_VERSION}}
- name: Post deployment tests
run: |
for i in $(ls test-positive/*.mmd); do docker run -v $(pwd):/data ${{env.DOCKER_IO_REPOSITORY}}:${{env.RELEASE_VERSION}} -i /data/$i; done
for i in $(ls test-positive/*.mmd); do cat $i | docker run -i -v $(pwd):/data ${{env.DOCKER_IO_REPOSITORY}}:${{env.RELEASE_VERSION}} -o /data/$i-stdin.svg; done
- name: Commit new version to the repository
run: |
git add package.json
git checkout master
git commit -m "Bump version ${{env.RELEASE_VERSION}}"
git push --no-verify
# For manual inspection of the generated artifacts
- uses: actions/upload-artifact@v4.3.0
with:
name: output
path: ./test-positive