Skip to content

Commit a04c0eb

Browse files
committed
release workflow
1 parent 50fb2c3 commit a04c0eb

File tree

2 files changed

+93
-73
lines changed

2 files changed

+93
-73
lines changed

.github/workflows/ci.yml

Lines changed: 56 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,71 @@
11
name: CI
2+
23
on:
3-
release:
4-
types:
5-
- published
64
push:
75
branches:
8-
- master
9-
paths:
10-
- .github/workflows/ci.yml
11-
- cmd/**
12-
- internal/**
13-
- pkg/**
14-
- .dockerignore
15-
- .golangci.yml
16-
- Dockerfile
17-
- go.mod
18-
- go.sum
6+
- main
7+
- develop
8+
- release/*
9+
- beta/*
10+
tags:
11+
- v*
1912
pull_request:
20-
paths:
21-
- .github/workflows/ci.yml
22-
- cmd/**
23-
- internal/**
24-
- pkg/**
25-
- .dockerignore
26-
- .golangci.yml
27-
- Dockerfile
28-
- go.mod
29-
- go.sum
13+
branches:
14+
- main
15+
- develop
16+
- release/*
17+
- beta/*
18+
release:
19+
types: [published]
20+
workflow_dispatch:
3021

3122
jobs:
3223
verify:
3324
runs-on: ubuntu-latest
34-
permissions:
35-
actions: read
36-
contents: read
37-
env:
38-
DOCKER_BUILDKIT: "1"
3925
steps:
4026
- uses: actions/checkout@v4
41-
42-
- uses: reviewdog/action-misspell@v1
27+
- uses: actions/setup-go@v5
4328
with:
44-
locale: "US"
45-
level: error
46-
exclude: |
47-
./internal/storage/servers.json
48-
*.md
49-
50-
- name: Linting
51-
run: docker build --target lint .
52-
53-
- name: Mocks check
54-
run: docker build --target mocks .
55-
56-
- name: Build test image
57-
run: docker build --target test -t test-container .
58-
59-
- name: Run tests in test container
60-
run: |
61-
touch coverage.txt
62-
docker run --rm --device /dev/net/tun \
63-
-v "$(pwd)/coverage.txt:/tmp/gobuild/coverage.txt" \
64-
test-container
65-
66-
- name: Build final image
67-
run: docker build -t final-image .
29+
go-version-file: go.mod
30+
cache: true
31+
- name: Verify
32+
run: make verify
6833

6934
codeql:
35+
name: CodeQL
7036
runs-on: ubuntu-latest
7137
permissions:
7238
actions: read
7339
contents: read
7440
security-events: write
41+
42+
strategy:
43+
fail-fast: false
44+
matrix:
45+
language: ["go"]
46+
7547
steps:
76-
- uses: actions/checkout@v4
77-
- uses: actions/setup-go@v5
78-
with:
79-
go-version: "^1.23"
80-
- uses: github/codeql-action/init@v3
48+
- name: Checkout repository
49+
uses: actions/checkout@v4
50+
51+
# Initializes the CodeQL tools for scanning.
52+
- name: Initialize CodeQL
53+
uses: github/codeql-action/init@v3
8154
with:
82-
languages: go
83-
- uses: github/codeql-action/autobuild@v3
84-
- uses: github/codeql-action/analyze@v3
55+
languages: ${{ matrix.language }}
56+
# If you wish to specify custom queries, you can do so here or in a config file.
57+
# By default, queries listed here will override any specified in a config file.
58+
# Prefix the list here with "+" to use these queries and queries in the config file.
59+
# For more information on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-qlpacks
60+
61+
- name: Autobuild
62+
uses: github/codeql-action/autobuild@v3
63+
64+
- name: Perform CodeQL Analysis
65+
uses: github/codeql-action/analyze@v3
8566

8667
publish:
8768
if: |
88-
github.repository == 'qdm12/gluetun' &&
8969
(
9070
github.event_name == 'push' ||
9171
github.event_name == 'release' ||
@@ -109,9 +89,8 @@ jobs:
10989
flavor: |
11090
latest=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
11191
images: |
112-
ghcr.io/qdm12/gluetun
113-
qmcgaw/gluetun
114-
qmcgaw/private-internet-access
92+
ghcr.io/${{ github.repository_owner }}/gluetun
93+
${{ github.repository_owner }}/gluetun
11594
tags: |
11695
type=ref,event=pr
11796
type=semver,pattern=v{{major}}.{{minor}}.{{patch}}
@@ -122,20 +101,24 @@ jobs:
122101
- uses: docker/setup-qemu-action@v3
123102
- uses: docker/setup-buildx-action@v3
124103

104+
# Login to Docker Hub (optional, only if you want to push to Docker Hub)
125105
- uses: docker/login-action@v3
106+
if: github.event_name != 'pull_request'
126107
with:
127-
username: qmcgaw
128-
password: ${{ secrets.DOCKERHUB_PASSWORD }}
108+
username: ${{ secrets.DOCKERHUB_USERNAME }}
109+
password: ${{ secrets.DOCKERHUB_TOKEN }}
129110

111+
# Login to GitHub Container Registry
130112
- uses: docker/login-action@v3
113+
if: github.event_name != 'pull_request'
131114
with:
132115
registry: ghcr.io
133-
username: qdm12
134-
password: ${{ github.token }}
116+
username: ${{ github.actor }}
117+
password: ${{ secrets.GITHUB_TOKEN }}
135118

136119
- name: Short commit
137120
id: shortcommit
138-
run: echo "::set-output name=value::$(git rev-parse --short HEAD)"
121+
run: echo "value=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
139122

140123
- name: Build and push final image
141124
uses: docker/build-push-action@v6
@@ -147,4 +130,4 @@ jobs:
147130
COMMIT=${{ steps.shortcommit.outputs.value }}
148131
VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
149132
tags: ${{ steps.meta.outputs.tags }}
150-
push: true
133+
push: ${{ github.event_name != 'pull_request' }}

.github/workflows/release.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Release
2+
on:
3+
push:
4+
tags:
5+
- 'v*'
6+
7+
jobs:
8+
release:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
12+
packages: write
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Generate changelog
19+
id: changelog
20+
run: |
21+
# Simple changelog generation
22+
echo "## Changes" > CHANGELOG.md
23+
git log --pretty=format:"- %s" $(git describe --tags --abbrev=0 HEAD^)..HEAD >> CHANGELOG.md
24+
echo "changelog<<EOF" >> $GITHUB_OUTPUT
25+
cat CHANGELOG.md >> $GITHUB_OUTPUT
26+
echo "EOF" >> $GITHUB_OUTPUT
27+
28+
- name: Create Release
29+
uses: actions/create-release@v1
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
with:
33+
tag_name: ${{ github.ref }}
34+
release_name: Release ${{ github.ref }}
35+
body: ${{ steps.changelog.outputs.changelog }}
36+
draft: false
37+
prerelease: false

0 commit comments

Comments
 (0)