name: CI on: workflow_dispatch: pull_request: push: tags: - 'v*' branches: - main permissions: {} jobs: build: runs-on: ubuntu-24.04 name: Build & Test permissions: contents: read packages: read env: GOEXPERIMENT: 'cgocheck2' steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: 'false' - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 with: go-version-file: 'go.mod' cache: "${{ github.actor != 'renovate[bot]' }}" - name: go build openvpn-auth-oauth2 run: go build ./cmd/openvpn-auth-oauth2 - name: go build openvpn-auth-oauth2.so run: go build -buildvcs=false -buildmode=c-shared -o "${RUNNER_TEMP}/openvpn-auth-oauth2.so" ./lib/openvpn-auth-oauth2 - name: go test run: go test ./... -short -shuffle=on -timeout 20s -race -covermode=atomic -coverprofile=coverage.out -coverpkg=./... - name: docker pull integration test image run: docker pull ghcr.io/jkroepke/openvpn-auth-oauth2/it:latest - name: go test (Integration Tests) run: go test -race -count=1 -timeout=15m -run '^TestIT(EnforceUniqueUser)?$' ./internal ./lib/openvpn-auth-oauth2 env: OPENVPN_IT_TEST: '1' PLUGIN_IT_TEST: '1' PLUGIN_IT_PLUGIN_PATH: "${{ runner.temp }}/openvpn-auth-oauth2.so" - uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0 env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} bench: runs-on: ubuntu-24.04 name: go bench permissions: contents: read steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: 'false' - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 with: go-version-file: 'go.mod' cache: "${{ github.actor != 'renovate[bot]' }}" - name: go test -bench run: go test ./... -timeout 20s -run='^$' -bench=. -benchmem goreleaser: runs-on: ubuntu-24.04 name: Test goreleaser permissions: contents: read steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: 'false' fetch-depth: 0 - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 with: go-version-file: 'go.mod' cache: "${{ github.actor != 'renovate[bot]' }}" - uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 # v2.2.1 with: version: 0.15.2 - uses: anchore/sbom-action/download-syft@3ad7283483fc7af8ff2b4ea19663c2d5ca935e26 # v0.24.2 - name: Write gpg sign key if: env.GPG_KEY != null run: echo "$GPG_KEY" > "$GPG_KEY_PATH" env: GPG_KEY_PATH: "${{ secrets.GPG_KEY_PATH }}" GPG_KEY: ${{ secrets.GPG_KEY }} - name: go build (with goreleaser) uses: goreleaser/goreleaser-action@f06c13b6b1a9625abc9e6e439d9c05a8f2190e94 # v7.2.3 with: # renovate: github=goreleaser/goreleaser version: v2.18.0 args: release --snapshot env: GITHUB_TOKEN: "" GPG_KEY_PATH: "" - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: name: dists path: dist/ lint: name: lint runs-on: ubuntu-24.04 permissions: contents: read steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: 'false' - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 with: go-version-file: 'go.mod' cache: "${{ github.actor != 'renovate[bot]' }}" - run: go mod tidy -diff - name: golangci-lint uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0 with: # renovate: github=golangci/golangci-lint version: v2.13.2 args: "--max-same-issues=0" super-lint: name: super-lint runs-on: ubuntu-24.04 permissions: contents: read steps: - name: Checkout Code uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: 'false' fetch-depth: 0 - name: Lint Code Base uses: super-linter/super-linter/slim@4ce20838b8ab83717e78138c5b3a1407148e0918 # v8.7.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} MULTI_STATUS: false LINTER_RULES_PATH: . GITHUB_ACTIONS_ZIZMOR_CONFIG_FILE: ./.github/zizmor.yml ENABLE_GITHUB_ACTIONS_STEP_SUMMARY: true ENABLE_GITHUB_PULL_REQUEST_SUMMARY_COMMENT: false SAVE_SUPER_LINTER_SUMMARY: true VALIDATE_ALL_CODEBASE: true VALIDATE_BASH: true VALIDATE_BASH_EXEC: true VALIDATE_EDITORCONFIG: true VALIDATE_ENV: true VALIDATE_GIT_MERGE_CONFLICT_MARKERS: true VALIDATE_GITHUB_ACTIONS: true VALIDATE_GITHUB_ACTIONS_ZIZMOR: true VALIDATE_GO_RELEASER: true VALIDATE_HTML: true VALIDATE_JSON: true VALIDATE_NATURAL_LANGUAGE: true # VALIDATE_MARKDOWN: false VALIDATE_RENOVATE: true VALIDATE_SHELL_SHFMT: true VALIDATE_SPELL_CODESPELL: true VALIDATE_XML: true VALIDATE_YAML: true publish: name: Publish package environment: Publish if: >- github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') needs: - build - lint - goreleaser - super-lint runs-on: ubuntu-24.04 permissions: contents: write id-token: write attestations: write steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: 'false' fetch-depth: 0 - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 with: go-version-file: 'go.mod' cache: true - uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 # v2.2.1 with: version: 0.15.2 - uses: anchore/sbom-action/download-syft@3ad7283483fc7af8ff2b4ea19663c2d5ca935e26 # v0.24.2 - name: GPG configuration run: |- echo "$GPG_KEY" > "$GPG_KEY_PATH" mkdir -p "$HOME/.gnupg" chmod 0700 "$HOME/.gnupg" echo "use-agent" > "$HOME/.gnupg/gpg.conf" echo "pinentry-mode loopback" >> "$HOME/.gnupg/gpg.conf" echo "allow-loopback-pinentry" > "$HOME/.gnupg/gpg-agent.conf" echo "max-cache-ttl 86400" >> "$HOME/.gnupg/gpg-agent.conf" echo "default-cache-ttl 86400" >> "$HOME/.gnupg/gpg-agent.conf" gpgconf --kill gpg-agent gpgconf --launch gpg-agent echo "$GPG_PASSPHRASE" | gpg --batch --yes --passphrase-fd 0 --import "$GPG_KEY_PATH" echo "1F34F95B4F30BC5B06E0D7CC3F619F17002790D8:6:" | gpg --import-ownertrust env: GPG_KEY_ID: ${{ vars.GPG_KEY_ID }} GPG_KEY: ${{ secrets.GPG_KEY }} GPG_PASSPHRASE: ${{ secrets.NFPM_PASSPHRASE }} GPG_KEY_PATH: "${{ secrets.GPG_KEY_PATH }}" - name: Run GoReleaser uses: goreleaser/goreleaser-action@f06c13b6b1a9625abc9e6e439d9c05a8f2190e94 # v7.2.3 with: # renovate: github=goreleaser/goreleaser version: v2.18.0 args: release --clean env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GORELEASER_CURRENT_TAG: ${{ github.ref_name }} NFPM_OPENVPN-AUTH-OAUTH2_PASSPHRASE: ${{ secrets.NFPM_PASSPHRASE }} GPG_KEY_PATH: ${{ secrets.GPG_KEY_PATH }} - name: Release APT repository run: | set -x gh release download "${GITHUB_REF_NAME}" -p "*.deb" -D tmp pushd tmp apt-ftparchive packages . | tee Packages | xz > Packages.xz apt-ftparchive release . > Release gpg --batch --yes --pinentry-mode loopback --passphrase "$GPG_PASSPHRASE" --clearsign -o InRelease Release gpg --batch --yes --pinentry-mode loopback --passphrase "$GPG_PASSPHRASE" --armor --detach-sign --sign -o Release.gpg Release gh release upload "${GITHUB_REF_NAME}" InRelease Packages Packages.xz Release Release.gpg --clobber popd env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GPG_PASSPHRASE: ${{ secrets.NFPM_PASSPHRASE }} - name: Publish Release run: gh release edit "${GITHUB_REF_NAME}" --draft=false env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2 with: subject-checksums: ./dist/checksums.txt