Skip to content

Commit d42440f

Browse files
authored
feat: use semantic-version (#3)
- Use the NPM package semantic-versioning to auto increment the versions
1 parent 95f4a4d commit d42440f

File tree

5 files changed

+36
-24
lines changed

5 files changed

+36
-24
lines changed

.github/workflows/build-release.yaml

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,26 @@ name: Build, Push, and Release
33
on:
44
push:
55
branches: [ main ]
6-
release:
7-
types: [created]
86

97
jobs:
10-
build-push-release:
8+
release:
119
runs-on: ubuntu-latest
1210
steps:
1311
- uses: actions/checkout@v4
1412
with:
1513
fetch-depth: 0
1614

15+
- name: Setup Node.js
16+
uses: actions/setup-node@v3
17+
with:
18+
node-version: 'lts/*'
19+
20+
- name: Install dependencies
21+
run: npm ci
22+
23+
- name: Set up QEMU
24+
uses: docker/setup-qemu-action@v3
25+
1726
- name: Set up Docker Buildx
1827
uses: docker/setup-buildx-action@v3
1928

@@ -24,33 +33,23 @@ jobs:
2433
username: ${{ github.actor }}
2534
password: ${{ secrets.GITHUB_TOKEN }}
2635

27-
- name: Get version
36+
- name: Release
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
run: npx semantic-release
40+
41+
- name: Get the version
2842
id: get_version
29-
run: |
30-
if [[ ${{ github.event_name }} == 'release' ]]; then
31-
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
32-
else
33-
echo "VERSION=$(git describe --tags --abbrev=0 | awk -F. '{OFS="."; $NF+=1; print $0}')" >> $GITHUB_OUTPUT
34-
fi
43+
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
3544

3645
- name: Build and push
3746
uses: docker/build-push-action@v5
3847
with:
3948
context: .
49+
platforms: linux/amd64,linux/arm64
4050
push: true
4151
tags: |
4252
ghcr.io/${{ github.repository }}:latest
4353
ghcr.io/${{ github.repository }}:${{ steps.get_version.outputs.VERSION }}
4454
cache-from: type=gha
4555
cache-to: type=gha,mode=max
46-
47-
- name: Create Release
48-
if: github.event_name != 'release'
49-
uses: actions/create-release@v1
50-
env:
51-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52-
with:
53-
tag_name: ${{ steps.get_version.outputs.VERSION }}
54-
release_name: Release ${{ steps.get_version.outputs.VERSION }}
55-
draft: false
56-
prerelease: false

.releaserc.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"branches": ["main"],
3+
"plugins": [
4+
"@semantic-release/commit-analyzer",
5+
"@semantic-release/release-notes-generator",
6+
"@semantic-release/github"
7+
]
8+
}

Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ LABEL org.opencontainers.image.source="https://github.com/roelde/devops-cicd-run
77
LABEL org.opencontainers.image.description="A Docker image for running IAC tools CI/CD pipelines."
88
LABEL org.opencontainers.image.licenses="MIT"
99

10-
1110
# Tool versions
1211
# renovate: datasource=github-releases depName=tofuutils/tenv
1312
ENV TENV_VERSION=v3.2.4
@@ -18,7 +17,7 @@ ENV OPENTOFU_VERSION=1.8.3
1817
# renovate: datasource=github-releases depName=pulumi/pulumi
1918
ENV PULUMI_VERSION=v3.136.1
2019
# renovate: datasource=repology depName=alpine_3_20/aws-cli versioning=loose
21-
ENV AWS_CLI_VERSION=2.18.0-r0
20+
ENV AWS_CLI_VERSION=2.18.4-r0
2221
# renovate: datasource=repology depName=alpine_3_20/ansible versioning=loose
2322
ENV ANSIBLE_VERSION=10.5.0-r0
2423
# renovate: datasource=repology depName=alpine_3_20/bash versioning=loose

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"devDependencies": {
3+
"semantic-release": "^19.0.5",
4+
"@semantic-release/github": "^8.0.7"
5+
}
6+
}

tests/structure-test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ commandTests:
1919
- name: "AWS CLI version"
2020
command: "aws"
2121
args: ["--version"]
22-
expectedOutput: ["aws-cli/2.18.0"]
22+
expectedOutput: ["aws-cli/2.18.4"]

0 commit comments

Comments
 (0)