chore: let GitHub actions handle releases automatically

This commit is contained in:
Ryan Dowling 2020-06-28 15:43:57 +10:00
parent f8df8da8de
commit a64b101072
No known key found for this signature in database
GPG key ID: 5539FCDB88950EFD
9 changed files with 143 additions and 78 deletions

62
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,62 @@
name: Release
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Mark gradle wrapper as executable
run: chmod a+x gradlew
- name: Test
run: ./gradlew test
- name: Build
run: ./gradlew build
- name: Read version
id: changelog
uses: pCYSl5EDgo/cat@master
with:
path: ./CHANGELOG.md
- name: Read version
id: version
uses: pCYSl5EDgo/cat@master
with:
path: ./src/main/resources/version
trim: true
- name: Remove stream from version
id: clean-version
uses: frabert/replace-string-action@v1.1
with:
string: ${{ steps.version.outputs.text }}
pattern: '([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\.?\w*'
replace-with: "$1"
- name: Release
uses: meeDamian/github-release@2.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: v${{ steps.clean-version.outputs.replaced }}
name: ${{ steps.clean-version.outputs.replaced }}
body: ${{ steps.changelog.outputs.text }}
prerelease: ${{ endsWith(steps.version.outputs.text, '.Beta') }}
allow_override: true
files: |
./dist/ATLauncher-${{ steps.clean-version.outputs.replaced }}.exe
./dist/ATLauncher-${{ steps.clean-version.outputs.replaced }}.zip
./dist/ATLauncher-${{ steps.clean-version.outputs.replaced }}.jar

View file

@ -1,4 +1,4 @@
name: Application
name: Run Tests
on: [push]
@ -17,18 +17,8 @@ jobs:
with:
java-version: ${{ matrix.java-version }}
- name: Marke gradle as executable
- name: Mark gradle wrapper as executable
run: chmod a+x gradlew
- name: Test
run: ./gradlew test
- name: Build
run: ./gradlew build
- name: Upload artifacts
uses: actions/upload-artifact@v2
if: ${{ matrix.java-version == '1.8' }}
with:
name: ATLauncher
path: dist/*

View file

@ -3,8 +3,6 @@
This changelog only contains the changes that are unreleased. For changes for individual releases, please visit the
[releases](https://github.com/ATLauncher/ATLauncher/releases) page on GitHub.
## 3.3.6.0
- Switch to using system property for Vanilla tab
- Fix debug logging not logging if request was cached or not correctly
- Add in SetupDialogComplete tracking event

View file

@ -143,11 +143,10 @@ code and the ATLauncher files it downloads.
Starting with version 3.2.1.0 a new versioning system was put into place. It works off the
following:
Reserved.Major.Minor.Revision.Build
Reserved.Major.Minor.Revision.Stream
So for 3.2.1.0.0 the major number is 2 and minor number is 1 and revision number is 0. Reserved is
used as a base, only incremented on complete rewrites. The build number is optional and should be 0
on releases.
So for 3.2.1.0 the major number is 2 and minor number is 1 and revision number is 0. Reserved is
used as a base, only incremented on complete rewrites. The stream is optional.
Major should be incremented when large changes/features are made.
@ -159,13 +158,14 @@ previous minor.
Build is used for beta releases allowing you to have higher version numbers but force users to
update when the real release comes.
Stream is used to define if it's a "Release" or a "Beta". When not provided, it defaults to "Release".
### Updating The Version
The version should be updated manually in the following files:
The version can be updated in a single place in the `/src/main/resources/version` file.
- CHANGELOG.md
- build.gradle
- /src/main/java/com/atlauncher/data/Constants.java
The stream value doesn't need to be provided, but should only ever be "Beta". When a release is ready
to go out, the stream should be removed from the version so that everything will automatically release.
## Translating

View file

@ -26,7 +26,7 @@ sourceCompatibility = '1.8'
targetCompatibility = '1.8'
group = 'com.atlauncher'
version = '3.3.6.0'
version = rootProject.file('src/main/resources/version').text.trim().replace(".Beta", "")
repositories {
mavenCentral()

View file

@ -17,8 +17,32 @@
*/
package com.atlauncher.data;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.stream.Collectors;
import com.atlauncher.App;
public class Constants {
public static final LauncherVersion VERSION = new LauncherVersion(3, 3, 6, 0);
static {
String versionFromFile = new BufferedReader(
new InputStreamReader(App.class.getResourceAsStream("/version"), StandardCharsets.UTF_8)).lines()
.collect(Collectors.joining("")).trim();
String[] versionParts = versionFromFile.split("\\.", 4);
String stream = "Release";
if (versionParts[3].endsWith(".Beta")) {
versionParts[3] = versionParts[3].replace(".Beta", "");
stream = "Beta";
}
VERSION = new LauncherVersion(Integer.parseInt(versionParts[0]), Integer.parseInt(versionParts[1]),
Integer.parseInt(versionParts[2]), Integer.parseInt(versionParts[3]), stream);
}
public static final LauncherVersion VERSION;
public static final String LAUNCHER_NAME = "ATLauncher";
public static final String DISCORD_CLIENT_ID = "589393213723246592";
public static final String GA_TRACKING_ID = "UA-88820616-7";

View file

@ -25,18 +25,18 @@ public class LauncherVersion {
private int major;
private int minor;
private int revision;
private int build = 0;
private String stream;
public LauncherVersion(int reserved, int major, int minor, int revision) {
this(reserved, major, minor, revision, 0);
this(reserved, major, minor, revision, "Release");
}
public LauncherVersion(int reserved, int major, int minor, int revision, int build) {
public LauncherVersion(int reserved, int major, int minor, int revision, String stream) {
this.reserved = reserved;
this.major = major;
this.minor = minor;
this.revision = revision;
this.build = build;
this.stream = stream;
}
public int getReserved() {
@ -55,8 +55,12 @@ public class LauncherVersion {
return this.revision;
}
public int getBuild() {
return this.build;
public String getStream() {
return this.stream;
}
public boolean isReleaseStream() {
return this.stream.equals("Release");
}
public boolean needsUpdate(LauncherVersion toThis) {
@ -80,9 +84,9 @@ public class LauncherVersion {
} else if (this.revision < toThis.getRevision()) {
return true;
} else {
return (toThis.getBuild() == 0 ? this.build != 0 : this.build < toThis.getBuild()); // Only
// update if the build is lower unless the version to update to is a 0 build which means it's
// official and should be updated to
// if versions are the same, update if current version is not a release stream
// but new version is in release stream
return !this.isReleaseStream() && toThis.isReleaseStream();
}
}
}
@ -91,15 +95,10 @@ public class LauncherVersion {
@Override
public String toString() {
if (this.build == 0) {
if (this.isReleaseStream()) {
return String.format("%d.%d.%d.%d", this.reserved, this.major, this.minor, this.revision);
} else {
return String.format("%d.%d.%d.%d Build %d", this.reserved, this.major, this.minor, this.revision, this
.build);
}
}
public boolean isBeta() {
return this.build != 0;
return String.format("%d.%d.%d.%d %s", this.reserved, this.major, this.minor, this.revision, this.stream);
}
}

View file

@ -0,0 +1 @@
3.3.6.0.Beta

View file

@ -1,3 +1,4 @@
/*
* ATLauncher - https://github.com/ATLauncher/ATLauncher
* Copyright (C) 2013-2019 ATLauncher
@ -15,7 +16,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import com.atlauncher.data.Constants;
import com.atlauncher.data.LauncherVersion;
import org.junit.jupiter.api.Test;
@ -24,64 +24,55 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class TestLauncherVersion {
private static LauncherVersion testVersion = new LauncherVersion(1, 0, 0, 0, "Release");
@Test
public void test() {
// Test same version - no update
assertFalse(Constants.VERSION
.needsUpdate(new LauncherVersion(Constants.VERSION.getReserved(), Constants.VERSION.getMajor(),
Constants.VERSION.getMinor(), Constants.VERSION.getRevision(), Constants.VERSION.getBuild())));
assertFalse(testVersion.needsUpdate(new LauncherVersion(testVersion.getReserved(), testVersion.getMajor(),
testVersion.getMinor(), testVersion.getRevision(), testVersion.getStream())));
// Test older Reserved - launcher had a big update
assertTrue(Constants.VERSION
.needsUpdate(new LauncherVersion(Constants.VERSION.getReserved() + 1, Constants.VERSION.getMajor(),
Constants.VERSION.getMinor(), Constants.VERSION.getRevision(), Constants.VERSION.getBuild())));
assertTrue(testVersion.needsUpdate(new LauncherVersion(testVersion.getReserved() + 1, testVersion.getMajor(),
testVersion.getMinor(), testVersion.getRevision(), testVersion.getStream())));
// Test older Major - launcher had major update
assertTrue(Constants.VERSION
.needsUpdate(new LauncherVersion(Constants.VERSION.getReserved(), Constants.VERSION.getMajor() + 1,
Constants.VERSION.getMinor(), Constants.VERSION.getRevision(), Constants.VERSION.getBuild())));
assertTrue(testVersion.needsUpdate(new LauncherVersion(testVersion.getReserved(), testVersion.getMajor() + 1,
testVersion.getMinor(), testVersion.getRevision(), testVersion.getStream())));
// Test older Minor - launcher had minor update
assertTrue(Constants.VERSION.needsUpdate(new LauncherVersion(Constants.VERSION.getReserved(),
Constants.VERSION.getMajor(), Constants.VERSION.getMinor() + 1, Constants.VERSION.getRevision(),
Constants.VERSION.getBuild())));
assertTrue(testVersion.needsUpdate(new LauncherVersion(testVersion.getReserved(), testVersion.getMajor(),
testVersion.getMinor() + 1, testVersion.getRevision(), testVersion.getStream())));
// Test older Revision - launcher had a bug fix
assertTrue(Constants.VERSION.needsUpdate(new LauncherVersion(Constants.VERSION.getReserved(),
Constants.VERSION.getMajor(), Constants.VERSION.getMinor(), Constants.VERSION.getRevision() + 1,
Constants.VERSION.getBuild())));
assertTrue(testVersion.needsUpdate(new LauncherVersion(testVersion.getReserved(), testVersion.getMajor(),
testVersion.getMinor(), testVersion.getRevision() + 1, testVersion.getStream())));
// Test older Build - launcher had a beta update
assertTrue(Constants.VERSION.needsUpdate(new LauncherVersion(Constants.VERSION.getReserved(),
Constants.VERSION.getMajor(), Constants.VERSION.getMinor(), Constants.VERSION.getRevision(),
Constants.VERSION.getBuild() + 1)));
// Test user has a beta stream but the real stream comes out
LauncherVersion betaBuild = new LauncherVersion(testVersion.getReserved(), testVersion.getMajor(),
testVersion.getMinor(), testVersion.getRevision(), "Beta");
LauncherVersion releaseBuild = new LauncherVersion(testVersion.getReserved(), testVersion.getMajor(),
testVersion.getMinor(), testVersion.getRevision(), "Release");
assertTrue(betaBuild.needsUpdate(releaseBuild));
// Test user has a beta build but the real build comes out
LauncherVersion testBuild = new LauncherVersion(Constants.VERSION.getReserved(), Constants.VERSION.getMajor(),
Constants.VERSION.getMinor(), Constants.VERSION.getRevision(), Constants.VERSION.getBuild() + 6);
LauncherVersion actualBuild = new LauncherVersion(Constants.VERSION.getReserved(), Constants.VERSION.getMajor(),
Constants.VERSION.getMinor(), Constants.VERSION.getRevision(), 0);
assertTrue(testBuild.needsUpdate(actualBuild));
// Test user has a release stream but a beta build comes out
assertFalse(releaseBuild.needsUpdate(betaBuild));
// Test newer Reserved - launcher dev version
assertFalse(Constants.VERSION
.needsUpdate(new LauncherVersion(Constants.VERSION.getReserved() - 1, Constants.VERSION.getMajor(),
Constants.VERSION.getMinor(), Constants.VERSION.getRevision(), Constants.VERSION.getBuild())));
assertFalse(testVersion.needsUpdate(new LauncherVersion(testVersion.getReserved() - 1, testVersion.getMajor(),
testVersion.getMinor(), testVersion.getRevision(), testVersion.getStream())));
// Test newer Major - launcher dev version
assertFalse(Constants.VERSION
.needsUpdate(new LauncherVersion(Constants.VERSION.getReserved(), Constants.VERSION.getMajor() - 1,
Constants.VERSION.getMinor(), Constants.VERSION.getRevision(), Constants.VERSION.getBuild())));
assertFalse(testVersion.needsUpdate(new LauncherVersion(testVersion.getReserved(), testVersion.getMajor() - 1,
testVersion.getMinor(), testVersion.getRevision(), testVersion.getStream())));
// Test newer Minor - launcher dev version
assertFalse(Constants.VERSION.needsUpdate(new LauncherVersion(Constants.VERSION.getReserved(),
Constants.VERSION.getMajor(), Constants.VERSION.getMinor() - 1, Constants.VERSION.getRevision(),
Constants.VERSION.getBuild())));
assertFalse(testVersion.needsUpdate(new LauncherVersion(testVersion.getReserved(), testVersion.getMajor(),
testVersion.getMinor() - 1, testVersion.getRevision(), testVersion.getStream())));
// Test newer Revision - launcher dev version
assertFalse(Constants.VERSION.needsUpdate(new LauncherVersion(Constants.VERSION.getReserved(),
Constants.VERSION.getMajor(), Constants.VERSION.getMinor(), Constants.VERSION.getRevision() - 1,
Constants.VERSION.getBuild())));
assertFalse(testVersion.needsUpdate(new LauncherVersion(testVersion.getReserved(), testVersion.getMajor(),
testVersion.getMinor(), testVersion.getRevision() - 1, testVersion.getStream())));
}
}