Compare commits

..

7 Commits

Author SHA1 Message Date
Lakhan Samani
36ea6a0a72 fix: image name 2021-09-11 22:46:42 +05:30
Lakhan Samani
f901b1fe4f feat: add docker build 2021-09-11 22:39:49 +05:30
Lakhan Samani
82991b9949 fix: mac build script 2021-09-11 22:32:18 +05:30
Lakhan Samani
a6a46b8d95 feat: add mac script
fix: release script
2021-09-11 22:30:05 +05:30
Lakhan Samani
5667d8dbb6 fix: env file path 2021-09-11 16:16:18 +05:30
Lakhan Samani
602c33a1eb fix: remove raw build command 2021-09-11 16:12:42 +05:30
Lakhan Samani
f5ca38ef0b fix: add go bin path to GITHUB_PATH 2021-09-11 16:10:12 +05:30
3 changed files with 43 additions and 13 deletions

View File

@@ -20,6 +20,8 @@ jobs:
export GO_HOME=/usr/bin/go && \ export GO_HOME=/usr/bin/go && \
export GOPATH=/go && \ export GOPATH=/go && \
export PATH=${GOPATH}/bin:${GO_HOME}/bin/:$PATH && \ export PATH=${GOPATH}/bin:${GO_HOME}/bin/:$PATH && \
echo "/usr/bin/go/bin" >> $GITHUB_PATH
echo "/usr/bin/x86_64-w64-mingw32-gcc" >> GITHUB_PATH
go version && \ go version && \
wget --no-check-certificate --progress=dot:mega https://github.com/wangyoucao577/assets-uploader/releases/download/v0.3.0/github-assets-uploader-v0.3.0-linux-amd64.tar.gz -O github-assets-uploader.tar.gz && \ wget --no-check-certificate --progress=dot:mega https://github.com/wangyoucao577/assets-uploader/releases/download/v0.3.0/github-assets-uploader-v0.3.0-linux-amd64.tar.gz -O github-assets-uploader.tar.gz && \
tar -zxf github-assets-uploader.tar.gz && \ tar -zxf github-assets-uploader.tar.gz && \
@@ -32,28 +34,36 @@ jobs:
run: go version run: go version
- name: Set VERSION env - name: Set VERSION env
run: echo VERSION=$(basename ${GITHUB_REF}) >> ${GITHUB_ENV} run: echo VERSION=$(basename ${GITHUB_REF}) >> ${GITHUB_ENV}
- name: Create build - name: Copy .env file
run: make clean && make run: mv .env.sample .env
- name: Package files for windows - name: Package files for windows
run: | run: |
make clean && CGO_ENABLED=1 GOOS=windows CC=/usr/bin/x86_64-w64-mingw32-gcc make make clean && CGO_ENABLED=1 GOOS=windows CC=/usr/bin/x86_64-w64-mingw32-gcc make
mv .env.sample .env && \
zip -vr authorizer-${VERSION}-windows-amd64.zip .env app build templates zip -vr authorizer-${VERSION}-windows-amd64.zip .env app build templates
- name: Package files for linux - name: Package files for linux
run: | run: |
make clean && CGO_ENABLED=1 make make clean && CGO_ENABLED=1 make
mv .env.sample .env && \
tar cvfz authorizer-${VERSION}-linux-amd64.tar.gz .env app build templates tar cvfz authorizer-${VERSION}-linux-amd64.tar.gz .env app build templates
- name: Upload assets - name: Upload assets
run: | run: |
github-assets-uploader -f authorizer-${VERSION}-windows-amd64.zip -mediatype application/zip -repo authorizerdev/authorizer -token ${{secrets.RELEASE_TOKEN}} -tag ${VERSION} && \ github-assets-uploader -f authorizer-${VERSION}-windows-amd64.zip -mediatype application/zip -repo authorizerdev/authorizer -token ${{secrets.RELEASE_TOKEN}} -tag ${VERSION} && \
github-assets-uploader -f authorizer-${VERSION}-linux-amd64.tar.gz -mediatype application/gzip -repo authorizerdev/authorizer -token ${{secrets.RELEASE_TOKEN}} -tag ${VERSION} && \ github-assets-uploader -f authorizer-${VERSION}-linux-amd64.tar.gz -mediatype application/gzip -repo authorizerdev/authorizer -token ${{secrets.RELEASE_TOKEN}} -tag ${VERSION}
- name: Log in to Docker Hub
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# - uses: wangyoucao577/go-release-action@v1.20 - name: Extract metadata (tags, labels) for Docker
# with: id: meta
# github_token: ${{ secrets.RELEASE_TOKEN }} uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
# goos: ${{ matrix.goos }} with:
# goarch: ${{ matrix.goarch }} images: lakhansamani/authorizer
# build_command: make clean && make
# md5sum: FALSE - name: Build and push Docker image
# extra_files: .env.sample app build template uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

2
.gitignore vendored
View File

@@ -6,3 +6,5 @@ build
.env .env
data.db data.db
.DS_Store .DS_Store
.env.local
*.tar.gz

18
scripts/build-mac.sh Normal file
View File

@@ -0,0 +1,18 @@
VERSION="$1"
make clean && CGO_ENABLED=1 make
FILE_NAME=authorizer-${VERSION}-darwin-amd64.tar.gz
tar cvfz ${FILE_NAME} .env app build templates
AUTH="Authorization: token $GITHUB_TOKEN"
RELASE_INFO=$(curl -sH "$AUTH" https://api.github.com/repos/authorizerdev/authorizer/releases/tags/${VERSION})
echo $RELASE_INFO
eval $(echo "$RELASE_INFO" | grep -m 1 "id.:" | grep -w id | tr : = | tr -cd '[[:alnum:]]=')
[ "$id" ] || { echo "Error: Failed to get release id for tag: $VERSION"; echo "$RELASE_INFO" | awk 'length($0)<100' >&2; exit 1; }
echo $id
GH_ASSET="https://uploads.github.com/repos/authorizerdev/authorizer/releases/$id/assets?name=$(basename $FILE_NAME)"
echo $GH_ASSET
curl -H $AUTH -H "Content-Type: $(file -b --mime-type $FILE_NAME)" --data-binary @$FILE_NAME $GH_ASSET
curl "$GITHUB_OAUTH_BASIC" --data-binary @"$FILE_NAME" -H "Authorization: token $GITHUB_TOKEN" -H "Content-Type: application/octet-stream" $GH_ASSET