Skip to content

Commit

Permalink
docker latest tag && tag config
Browse files Browse the repository at this point in the history
  • Loading branch information
wovnep committed Jan 17, 2023
1 parent 74ce992 commit 556ba83
Show file tree
Hide file tree
Showing 12 changed files with 169 additions and 94 deletions.
13 changes: 8 additions & 5 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# Github
USERNAME=user
REPO=repo
# Private repo required an api key
API_KEY=
USERNAME=wovnep
REPO=tauri-updater
# Private repository required to have an api key
API_KEY=
# If the Github tag start with a prefix set this to the prefix. eg: Value for v1.3.0 would be v.
TAG_STRUCTURE=v

# Windows
DEFAULT_LANG=en-US

# Update
SIGNATURE=false #boolean
# If you build with a signature set this to true. Make sure you have .sig file in the release. Eg: In https://github.com/wovnep/tauri-updater/releases/tag/v0.1.0 updater_0.1.0_x64_en-US.msi.zip.sig file.
SIGNATURE=false
7 changes: 2 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,19 @@ jobs:
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v3
with:
push: true
tags: wovnep/tauri-update-server:${{ github.ref_name }}

platforms: linux/amd64,linux/arm64
tags: wovnep/tauri-update-server:latest,wovnep/tauri-update-server:${{ github.ref_name }}
uses: actions/checkout@v3
- name: Docker Hub README update
uses: peter-evans/dockerhub-description@v3
Expand Down
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"trailingComma": "es5",
"tabWidth": 4,
"semi": true,
"singleQuote": true,
"printWidth": 200
}
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ RUN npm run build

EXPOSE 8080

ENV DEFAULT_LANG=en-US
ENV SIGNATURE=false
ENV TAG_STRUCTURE=v

CMD ["npm", "start"]
70 changes: 58 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,76 @@

Server to update your tauri app. Supports github public/private repositories.

## Usage

```bash
git clone https://github.com/wovnep/tauri-update-server.git
cd tauri-update-server
npm install
npm run build && npm start
```

In `tauri.conf.json`
```json
...
"updater": {
"active": true,
"endpoints": [
"http://localhost:8080/update?current_version={{current_version}}&target={{target}}&arch={{arch}}"
],
"dialog": true,
"pubkey": "xxx"
}
...
```

## Docker

#### Image:

```
docker pull wovnep/tauri-update-server:latest
```
#### CLI usage:

```bash
docker run \
-e USERNAME='user' \
-e REPO='repository' \
-e TAG_STRUCTURE='v' \
-e API_KEY='xxxxxxxx' \
-e DEFAULT_LANG='en-US' \
-e SIGNATURE='true' \
wovnep/tauri-update-server:latest
```

#### Docker compose usage:
#### Docker compose:

```yaml
services:
updater:
container_name: updater
image: wovnep/tauri-update-server
update-server:
container_name: Tauri update server
image: wovnep/tauri-update-server:latest
ports:
- "3000:8080"
environment:
- USERNAME=wovnep
- REPO=tauri-updater
- API_KEY=${API_KEY}
- TAG_STRUCTURE=v
- DEFAULT_LANG=en-US
- SIGNATURE=true
```
## Environment variables
|Name |Required |Description |
| ----------- | ----------- | ----------- |
|USERNAME |true |Github username/repo owner|
|REPO |true |Github repository of the project|
|API_KEY |false |[Personal access token](https://github.com/settings/tokens). Default: false|
|DEFAULT_LANG |true(windows)|Windows default language app build in. Default: en-US|
|SIGNATURE |false |If you enabled signature enable this. Default: false
|Name |Required |Default |Description|
| ----------- | ----------- | ----------- |-----------|
|USERNAME |true |null |Github username/owner/organization|
|REPO |true |null |Github repository of the project|
|DEFAULT_LANG |false |en-US |Windows build language. [Supported languages](https://tauri.app/v1/api/config#wixconfig.language).|
|TAG_STRUCTURE|true |v |Release tag prefix. eg: v in v1.23.4|
|SIGNATURE |false |false |If you [sign updates](https://tauri.app/v1/guides/distribution/updater#signing-updates), Set this to true.|
|API_KEY |false |null |[Personal access token](https://github.com/settings/tokens).|
## Development
Expand All @@ -43,7 +80,16 @@ services:
npm run build
```

**Start**
```
npm start
```

**Dev**
```
npm run dev
```
```

## License

MIT
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:
updater:
container_name: updater
image: wovnep/tauri-update-server
image: wovnep/tauri-update-server:0.1.0
ports:
- "3000:8080"
environment:
Expand Down
36 changes: 18 additions & 18 deletions lib/getReleases.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
const extensions = [
{ target: "windows", arch: "x86_64", extension: `x64_${process.env.DEFAULT_LANG}.msi.zip` },
{ target: "windows", arch: "i686", extension: `x86_${process.env.DEFAULT_LANG}.msi.zip` },
{ target: "darwin", arch: "x86_64", extension: 'x64.app.tar.gz' },
{ target: "darwin", arch: "aarch64", extension: 'aarch64.app.tar.gz' },
{ target: "linux", arch: "x86_64", extension: 'amd64.AppImage.tar.gz' }
]
export const getReleases = (assets: Array<any>, target: string, arch: string):any => {
let data = {} || undefined
const targetExtension = extensions.filter(element => target === element.target && arch === element.arch)[0]
if(targetExtension){
assets.forEach(release => {
if(release.name.endsWith(targetExtension.extension)){
data["url"] = release.browser_download_url
data["date"] = release.created_at
{ target: 'windows', arch: 'x86_64', extension: `x64_${process.env.DEFAULT_LANG}.msi.zip` },
{ target: 'windows', arch: 'i686', extension: `x86_${process.env.DEFAULT_LANG}.msi.zip` },
{ target: 'darwin', arch: 'x86_64', extension: 'x64.app.tar.gz' },
{ target: 'darwin', arch: 'aarch64', extension: 'aarch64.app.tar.gz' },
{ target: 'linux', arch: 'x86_64', extension: 'amd64.AppImage.tar.gz' },
];
export const getReleases = (assets: Array<any>, target: string, arch: string): any => {
let data = {} || undefined;
const targetExtension = extensions.filter((element) => target === element.target && arch === element.arch)[0];
if (targetExtension) {
assets.forEach((release) => {
if (release.name.endsWith(targetExtension.extension)) {
data['url'] = release.browser_download_url;
data['date'] = release.created_at;
} else {
if(process.env.SIGNATURE && release.name.endsWith(targetExtension.extension + ".sig")){
data["assets"] = release.url
if (process.env.SIGNATURE === 'true' && release.name.endsWith(targetExtension.extension + '.sig')) {
data['assets'] = release.url;
}
}
});
}
return data
}
return data;
};
34 changes: 17 additions & 17 deletions lib/github.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import dotenv from "dotenv"
dotenv.config()
import dotenv from 'dotenv';
dotenv.config();

const baseURL = `https://api.github.com/repos/${process.env.USERNAME}/${process.env.REPO}/releases/latest`
const baseURL = `https://api.github.com/repos/${process.env.USERNAME}/${process.env.REPO}/releases/latest`;

export const github = async() => {
export const github = async () => {
const config = {
headers: {
"Authorization": `Bearer ${process.env.API_KEY}`
}
}
const response = await fetch(baseURL, process.env.API_KEY? config : undefined)
return response.json()
}
export const getSignature = async(assetsURL:string) => {
Authorization: `Bearer ${process.env.API_KEY}`,
},
};
const response = await fetch(baseURL, process.env.API_KEY ? config : undefined);
return response.json();
};
export const getSignature = async (assetsURL: string) => {
const response = await fetch(assetsURL, {
headers: {
"Accept": "application/octet-stream",
"Authorization": process.env.API_KEY ? `Bearer ${process.env.API_KEY}` : undefined
}
})
return response.text()
}
Accept: 'application/octet-stream',
Authorization: process.env.API_KEY ? `Bearer ${process.env.API_KEY}` : undefined,
},
});
return response.text();
};
12 changes: 6 additions & 6 deletions lib/template.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { getSignature } from "./github.js"
export const template = async(release:any, version:string, oldversion:string) => {
return{
import { getSignature } from './github.js';
export const template = async (release: any, version: string, oldversion: string) => {
return {
url: release.url,
version: version,
notes: `Changelog: https://github.com/${process.env.USERNAME}/${process.env.REPO}/compare/v${oldversion}...v${version}`,
pub_date: release.date,
signature: release.assets ? await getSignature(release.assets) : ""
}
}
signature: release.assets ? await getSignature(release.assets) : '',
};
};
24 changes: 20 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
"scripts": {
"start": "node dist/src/index.js",
"dev": "tsc && node dist/src/index.js",
"build": "tsc"
"build": "tsc",
"prettier": "prettier -w src/**/*.ts lib/**/*.ts"
},
"author": "wovnep",
"license": "ISC",
"devDependencies": {
"@types/express": "^4.17.15",
"@types/node": "^18.11.18",
"prettier": "2.8.3",
"typescript": "^4.9.4"
},
"dependencies": {
Expand Down
Loading

0 comments on commit 556ba83

Please sign in to comment.