Skip to content

Commit e768c16

Browse files
committed
feat(typescript-node): adds release workflow
1 parent 95edf50 commit e768c16

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: TypeScript Node - Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build-and-push:
9+
runs-on: ubuntu-latest
10+
environment: PRODUCTION
11+
steps:
12+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
13+
14+
- name: Set up Docker Buildx
15+
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
16+
17+
- name: Login to Docker Hub
18+
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
19+
with:
20+
username: ${{ vars.DOCKERHUB_USERNAME }}
21+
password: ${{ secrets.DOCKERHUB_TOKEN }}
22+
23+
- name: Login to GHCR
24+
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
25+
with:
26+
registry: ghcr.io
27+
username: ${{ github.repository_owner }}
28+
password: ${{ secrets.GH_TOKEN }}
29+
30+
- name: Generate build tag
31+
run: |
32+
RELEASE_NAME="${{ github.event.release.name }}"
33+
34+
if [[ -z "$RELEASE_NAME" ]]; then
35+
echo "Error: Release name is empty"
36+
exit 1
37+
fi
38+
39+
# Check if it's a valid semver (with optional 'v' prefix)
40+
if [[ "$RELEASE_NAME" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$ ]]; then
41+
# Strip 'v' prefix if present
42+
CLEAN_VERSION="${RELEASE_NAME#v}"
43+
echo "BUILD_TAG=$CLEAN_VERSION" >> $GITHUB_ENV
44+
else
45+
echo "Error: Release name '$RELEASE_NAME' is not a valid semantic version"
46+
exit 1
47+
fi
48+
49+
- name: Build & Push image to registries
50+
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
51+
with:
52+
context: source/typescript-node
53+
push: true
54+
tags: |
55+
${{ vars.DOCKERHUB_USERNAME }}/typescript-node:${{ env.BUILD_TAG }}
56+
${{ vars.DOCKERHUB_USERNAME }}/typescript-node:latest
57+
ghcr.io/${{ github.repository_owner }}/typescript-node:${{ env.BUILD_TAG }}
58+
ghcr.io/${{ github.repository_owner }}/typescript-node:latest
59+
cache-from: type=gha
60+
cache-to: type=gha,mode=max

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ This repository provides opinionated [devcontainer](https://containers.dev/) ima
44

55
## Available Devcontainers
66
- [Typescript & Node.js](https://hub.docker.com/r/6thpath/typescript-node)
7+
- From [Docker Hub](https://hub.docker.com/r/6thpath/typescript-node)
8+
- From [GitHub Container Registry](https://github.com/6thpath/devcontainer-images/pkgs/container/typescript-node)

0 commit comments

Comments
 (0)