-
Notifications
You must be signed in to change notification settings - Fork 2
126 lines (109 loc) · 3.87 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
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: Release
on:
workflow_dispatch:
inputs:
title:
description: "Release title (blank for tag)"
required: false
dry-run:
description: "Dry run mode"
required: false
default: false
jobs:
release:
runs-on: ubuntu-latest
environment: deployment
name: Publish and Release
steps:
- name: Source checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ssh-key: ${{ secrets.DEPLOY_KEY }}
- name: Install node 20
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
registry-url: "https://registry.npmjs.org"
- name: Configure git
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
- name: Setup qemu
uses: docker/setup-qemu-action@v3
with:
platforms: ${{ vars.PLATFORMS }}
- name: Setup docker buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Install project modules
run: npm ci --production
- name: Decide new version
id: bump
run: echo "version=$(node src/cli.js | jq '.next' | tr -d '"')" >> "$GITHUB_OUTPUT"
- name: Update package version
run: npm version ${{ steps.bump.outputs.version }} --no-git-tag-version
- name: Push new version
if: github.event.inputs.dry-run != 'true'
run: |
git add package.json package-lock.json
git commit -m "build: updated package with ${{ steps.bump.outputs.version }} [skip ci]"
git push
- name: Set a release name
id: release_name
uses: actions/github-script@v7
with:
script: |
var retval = '${{ steps.bump.outputs.version }}'
if ('${{ github.event.inputs.title }}') {
retval = retval.concat(' - ${{ github.event.inputs.title }}')
}
core.setOutput('value', retval)
- name: Create a release
if: github.event.inputs.dry-run != 'true'
uses: actions/github-script@v7
with:
script: |
const repo_name = context.payload.repository.full_name
const response = await github.request('POST /repos/' + repo_name + '/releases', {
tag_name: '${{ steps.bump.outputs.version }}',
name: '${{ steps.release_name.outputs.value }}',
generate_release_notes: true
})
core.setOutput('html_url', response.data.html_url)
- name: Publish package
if: github.event.inputs.dry-run != 'true'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --access=public
- name: Extract meta for image
id: meta
uses: docker/metadata-action@v5
with:
images: tomerfi/version-bumper
labels: |
org.opencontainers.image.version=${{ steps.bump.outputs.version }}
- name: Push image
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event.inputs.dry-run != 'true' }}
platforms: ${{ vars.PLATFORMS }}
tags: |
tomerfi/version-bumper:latest
tomerfi/version-bumper:${{ steps.bump.outputs.version }}
cache-from: type=gha
cache-to: type=gha,mode=max
labels: ${{ steps.meta.outputs.labels }}
- name: Update image description on docker hub
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: tomerfi/version-bumper