-
Notifications
You must be signed in to change notification settings - Fork 0
101 lines (88 loc) · 2.77 KB
/
github-ci.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
name: Substrate publisher image build and release automation workflow
on:
push:
tags:
- '*'
branches:
- main
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push-publisher:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# Set the list of tags for the Docker image
tags: |
type=ref,event=tag
type=raw,value=latest
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./
file: ./docker/Dockerfile
# No need for build args at the build time, will be set at the runtime
# build_args: |
# NATS=${{ vars.NATS }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
create-release:
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
needs: build-and-push-publisher
steps:
- name: Check out the repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create package.json with latest tag
run: |
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`)
previous_tag=$(git describe --tags --abbrev=0 HEAD^)
echo "Latest tag is $latest_tag"
echo "Previous tag is $previous_tag"
echo "{\"version\": \"${latest_tag#v}\"}" > package.json
echo "LATEST_TAG=${latest_tag}" >> $GITHUB_ENV
echo "PREVIOUS_TAG=${previous_tag}" >> $GITHUB_ENV
- name: "Generate release changelog"
id: changelog
uses: heinrichreimer/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
unreleased: false
onlyLastTag: true
# sinceTag: ${{ env.PREVIOUS_TAG }}
dueTag: ${{ env.LATEST_TAG }}
output: "CHANGELOG.md"
dateFormat: "%Y-%m-%d"
- name: Tidy up the changelog
run: sed -i '$ d' CHANGELOG.md
- name: Print the changelog
run: cat CHANGELOG.md
- name: Release
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ env.LATEST_TAG }}
body_path: CHANGELOG.md
draft: false
prerelease: false
files: |
CHANGELOG.md