-
Notifications
You must be signed in to change notification settings - Fork 9
89 lines (86 loc) · 3.33 KB
/
release.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
# validate YAML
# https://codebeautify.org/yaml-validator
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
name: Create Release
jobs:
build:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
# https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions
- name: Find tag name
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Generate release .zip file
# -x excludes those directories
run: zip -r kort-${{ env.RELEASE_VERSION }}.zip . -x ".git/*" ".github/*"
- name: Create Release
id: create_release
# https://github.com/marketplace/actions/create-a-release
uses: actions/create-release@v1
env:
# This token is provided by Actions, you do not need to create your own token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.RELEASE_VERSION }}
release_name: Release ${{ env.RELEASE_VERSION }}
body: Release ${{ env.RELEASE_VERSION }}
draft: false
prerelease: false
- name: Upload Release Asset
id: upload-release-asset
# https://github.com/actions/upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object,
# which include a `upload_url`. See this blog post for more
# info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./kort-${{ env.RELEASE_VERSION }}.zip
asset_name: kort-${{ env.RELEASE_VERSION }}.zip
asset_content_type: application/zip
# install Node.js
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 14
# Specifies the registry, this field is required!
registry-url: https://registry.npmjs.org/
- run: npm install
- name: Publish to npmjs.com
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: all
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Build and push docker
id: docker_build
# https://github.com/docker/build-push-action
uses: docker/build-push-action@v3
with:
push: true
tags: ghcr.io/carlsonp/kort:latest
platforms: linux/amd64,linux/arm64
# https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md
cache-from: type=registry,ref=ghcr.io/carlsonp/kort:latest
cache-to: type=inline
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}