Skip to content

Merge pull request #56 from tarosky/issue/55 #131

Merge pull request #56 from tarosky/issue/55

Merge pull request #56 from tarosky/issue/55 #131

Workflow file for this run

name: CI
on:
pull_request:
branches:
- master
push:
branches:
- master
- issue/*
# - dev/harai
env:
ACCESS_KEY_ID: AKIAQGFE5ESVAHTVHJGK
AWS_ACCOUNT_ID: '013230744746'
S3_BUCKET: gutenberg-ext-imgserver-tests3bucket-t4nafmwadd9f
PUBLIC_CONTENT_S3_BUCKET: gutenberg-ext-imgserver-tests3publicbucket-1aeju3m5t5nuy
GO_VERSION: 1.23.2
defaults:
run:
shell: bash
jobs:
build:
# Use old distribution to support older Glibc.
#
# Glibc versions:
#
# ubuntu-20.04: GLIBC 2.31
# ubuntu-22.04: GLIBC 2.35
# ubuntu-24.04: GLIBC 2.39
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@main
- uses: actions/setup-go@main
with:
go-version: '~${{env.GO_VERSION}}'
- run: echo "$ACCESS_KEY_ID" > config/test/access-key-id
- run: echo "$AWS_ACCOUNT_ID" > config/test/aws-account-id
- run: echo "$S3_BUCKET" > config/test/s3-bucket
- run: echo "$PUBLIC_CONTENT_S3_BUCKET" > config/test/public-content-s3-bucket
- run: echo "$TEST_AWS_SECRET_ACCESS_KEY" > config/test/secret-access-key
env:
TEST_AWS_SECRET_ACCESS_KEY: ${{secrets.TEST_AWS_SECRET_ACCESS_KEY}}
- run: go install github.com/ahmetb/govvv@latest
- name: Generate build number
uses: onyxmueller/build-tag-number@main
with:
token: ${{secrets.GITHUB_TOKEN}}
prefix: build_number_generator
- name: Print new build number
run: echo "Build number is $BUILD_NUMBER"
- name: Save the build number
run: echo "$BUILD_NUMBER" > work/BUILD_NUMBER
- name: Embed build number into code
run: echo "build-$BUILD_NUMBER" > ./VERSION
- run: ~/go/bin/govvv build -o work/imgserver .
- uses: actions/upload-artifact@main
with:
name: artifact
path: work/imgserver
if-no-files-found: error
- uses: actions/upload-artifact@main
with:
name: build-number
path: work/BUILD_NUMBER
if-no-files-found: error
test:
runs-on: ubuntu-24.04
permissions:
checks: write
pull-requests: write
steps:
- uses: actions/checkout@main
- uses: actions/setup-go@main
with:
go-version: '~${{env.GO_VERSION}}'
- run: echo "$ACCESS_KEY_ID" > config/test/access-key-id
- run: echo "$AWS_ACCOUNT_ID" > config/test/aws-account-id
- run: echo "$S3_BUCKET" > config/test/s3-bucket
- run: echo "$PUBLIC_CONTENT_S3_BUCKET" > config/test/public-content-s3-bucket
- run: echo "$TEST_AWS_SECRET_ACCESS_KEY" > config/test/secret-access-key
env:
TEST_AWS_SECRET_ACCESS_KEY: ${{secrets.TEST_AWS_SECRET_ACCESS_KEY}}
- run: go install github.com/jstemmer/go-junit-report@latest
- run: go test -v ./... 2>&1 | tee work/test.log
- run: go-junit-report < work/test.log | tee work/report.xml
- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@master
if: always()
with:
files: work/report.xml
release:
needs:
- build
- test
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-24.04
steps:
- uses: actions/download-artifact@main
with:
name: artifact
- uses: actions/download-artifact@main
with:
name: build-number
- name: set BUILD_NUMBER
run: echo "BUILD_NUMBER=$(< ./BUILD_NUMBER)" >> $GITHUB_ENV
- id: create_release
uses: actions/create-release@main
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
tag_name: build-${{env.BUILD_NUMBER}}
release_name: Build ${{env.BUILD_NUMBER}}
draft: false
prerelease: false
- uses: actions/upload-release-asset@main
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
upload_url: ${{steps.create_release.outputs.upload_url}}
asset_path: ./imgserver
asset_name: imgserver.build-${{env.BUILD_NUMBER}}-linux-amd64
asset_content_type: application/octet-stream