-
-
Notifications
You must be signed in to change notification settings - Fork 111
116 lines (95 loc) · 3.88 KB
/
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
113
114
115
116
---
name: publish
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'
jobs:
npm:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@8b122486cedac8393e77aa9734c3528886e4a1a8
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@dc7b9719a96d48369863986a06765841d7ea23f6
- name: Log in to Docker Hub
uses: docker/login-action@42d299face0c5c43a0487c477f595ac9cf22f1a7
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@e5622373a38e60fb6d795a4421e56882f2d7a681
with:
images: freyrcli/freyrjs
tags: |
type=ref,event=tag
type=semver,pattern={{raw}}
- name: Build and push Docker image
uses: docker/build-push-action@7f9d37fa544684fb73bfe4835ed7214c255ce02b
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
release:
runs-on: ubuntu-latest
needs: [ npm, docker ]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
# fetch tags for cargo ws publish
# might be a simple `fetch-tags: true` option soon, see https://github.com/actions/checkout/pull/579
fetch-depth: 0
- name: Bootstrap
run: |
git config user.name github-actions
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
GIT_CURRENT_TAG="${GITHUB_REF#refs/tags/}"
echo "::notice::Current Git Tag: \"${GIT_CURRENT_TAG}\""
echo "GIT_CURRENT_TAG=${GIT_CURRENT_TAG}" >> "$GITHUB_ENV"
GIT_CURRENT_TAG_COMMIT="$(git rev-list -n1 "${GIT_CURRENT_TAG}")"
GIT_PREVIOUS_REF="$(git describe --tags --abbrev=0 "${GIT_CURRENT_TAG_COMMIT}^1" 2>/dev/null || git rev-list --max-parents=0 HEAD)"
echo "::notice::Previous Git Tag / Ref: \"${GIT_PREVIOUS_REF}\""
echo "GIT_PREVIOUS_REF=${GIT_PREVIOUS_REF}" >> "$GITHUB_ENV"
echo "FREYR_VERSION=${GIT_CURRENT_TAG#v}" >> "$GITHUB_ENV"
- name: Extract release notes
id: extract-release-notes
uses: ffurrer2/extract-release-notes@c24866884b7a0d2fd2095be2e406b6f260479da8
- name: Create release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.GIT_CURRENT_TAG }}
release_name: ${{ env.GIT_CURRENT_TAG }}
body: |
[![][npm-badge]][npm-url] [![][docker-badge]][docker-url] [![][github-badge]][github-url]
## What's changed?
${{ steps.extract-release-notes.outputs.release_notes }}
**Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ env.GIT_PREVIOUS_REF }}...${{ env.GIT_CURRENT_TAG }}
[npm-url]: https://www.npmjs.com/package/freyr/v/${{ env.FREYR_VERSION }}
[npm-badge]: https://img.shields.io/badge/npm-gray?logo=npm
[docker-url]: https://hub.docker.com/r/freyrcli/freyrjs/tags?name=v${{ env.FREYR_VERSION }}
[docker-badge]: https://img.shields.io/badge/docker-gray?logo=docker
[github-url]: https://github.com/miraclx/freyr-js/releases/tag/v${{ env.FREYR_VERSION }}
[github-badge]: https://img.shields.io/badge/github-gray?logo=github